2020-07-02 10:34:05 +12:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Appwrite\Extend;
|
|
|
|
|
|
|
|
use PDO as PDONative;
|
|
|
|
use PDOStatement as PDOStatementNative;
|
|
|
|
|
2020-07-03 03:19:33 +12:00
|
|
|
class PDOStatement extends PDOStatementNative
|
2020-07-02 10:34:05 +12:00
|
|
|
{
|
|
|
|
/**
|
2020-07-02 21:02:43 +12:00
|
|
|
* @var PDO
|
2020-07-02 10:34:05 +12:00
|
|
|
*/
|
|
|
|
protected $pdo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var PDOStatementNative
|
|
|
|
*/
|
|
|
|
protected $PDOStatement;
|
|
|
|
|
2020-07-02 21:02:43 +12:00
|
|
|
public function __construct(PDO &$pdo, PDOStatementNative $PDOStatement)
|
2020-07-02 10:34:05 +12:00
|
|
|
{
|
|
|
|
$this->pdo = $pdo;
|
|
|
|
$this->PDOStatement = $PDOStatement;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bindValue($parameter, $value, $data_type = PDONative::PARAM_STR)
|
|
|
|
{
|
|
|
|
$result = $this->PDOStatement->bindValue($parameter, $value, $data_type);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bindParam($parameter, &$variable, $data_type = PDONative::PARAM_STR, $length = null, $driver_options = null)
|
|
|
|
{
|
|
|
|
$result = $this->PDOStatement->bindParam($parameter, $variable, $data_type, $length, $driver_options);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null)
|
|
|
|
{
|
|
|
|
$result = $this->PDOStatement->bindColumn($column, $param, $type, $maxlen, $driverdata);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute($input_parameters = null)
|
|
|
|
{
|
2020-07-02 21:02:43 +12:00
|
|
|
try {
|
|
|
|
$result = $this->PDOStatement->execute($input_parameters);
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
// throw new Exception('My Error: ' .$th->getMessage());
|
2020-07-03 03:19:33 +12:00
|
|
|
sleep(1);
|
2020-07-02 21:02:43 +12:00
|
|
|
$this->pdo->reconnect();
|
|
|
|
$result = $this->PDOStatement->execute($input_parameters);
|
|
|
|
}
|
2020-07-02 10:34:05 +12:00
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function fetch($fetch_style = PDONative::FETCH_ASSOC, $cursor_orientation = PDONative::FETCH_ORI_NEXT, $cursor_offset = 0)
|
|
|
|
{
|
|
|
|
$result = $this->PDOStatement->fetch($fetch_style, $cursor_orientation, $cursor_offset);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function fetchAll()
|
|
|
|
{
|
|
|
|
$result = $this->PDOStatement->fetchAll();
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|