appwrite/src/Appwrite/Extend/PDOStatement.php

72 lines
1.9 KiB
PHP
Raw Normal View History

2020-07-01 22:34:05 +00:00
<?php
namespace Appwrite\Extend;
use PDO as PDONative;
use PDOStatement as PDOStatementNative;
2020-07-02 15:19:33 +00:00
class PDOStatement extends PDOStatementNative
2020-07-01 22:34:05 +00:00
{
/**
2020-07-02 09:02:43 +00:00
* @var PDO
2020-07-01 22:34:05 +00:00
*/
protected $pdo;
/**
* @var PDOStatementNative
*/
protected $PDOStatement;
2020-07-02 09:02:43 +00:00
public function __construct(PDO &$pdo, PDOStatementNative $PDOStatement)
2020-07-01 22:34:05 +00: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 09:02:43 +00:00
try {
$result = $this->PDOStatement->execute($input_parameters);
} catch (\Throwable $th) {
$this->pdo->reconnect();
$result = $this->PDOStatement->execute($input_parameters);
}
2020-07-01 22:34:05 +00: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;
}
2020-07-02 17:37:24 +00:00
public function fetchAll($how = null, $class_name = null, $ctor_args = null)
2020-07-01 22:34:05 +00:00
{
$result = $this->PDOStatement->fetchAll();
return $result;
}
}