appwrite/src/Appwrite/Extend/PDO.php

66 lines
1.3 KiB
PHP
Raw Normal View History

2020-07-01 22:34:05 +00:00
<?php
namespace Appwrite\Extend;
use PDO as PDONative;
2020-07-02 15:19:33 +00:00
class PDO extends PDONative
2020-07-01 22:34:05 +00:00
{
/**
* @var PDONative
*/
protected $pdo;
/**
* @var mixed
*/
protected $dsn;
/**
* @var mixed
*/
protected $username;
/**
* @var mixed
*/
protected $passwd;
/**
* @var mixed
*/
protected $options;
/**
* Create A Proxy PDO Object
*/
public function __construct($dsn, $username = null, $passwd = null, $options = null)
{
$this->dsn = $dsn;
$this->username = $username;
$this->passwd = $passwd;
$this->options = $options;
$this->pdo = new PDONative($dsn, $username, $passwd, $options);
}
public function setAttribute($attribute, $value)
{
return $this->pdo->setAttribute($attribute, $value);
}
public function prepare($statement, array $driver_options = [])
{
2020-07-02 09:02:43 +00:00
return new PDOStatement($this, $this->pdo->prepare($statement, $driver_options));
2020-07-01 22:34:05 +00:00
}
public function quote($string, $parameter_type = PDONative::PARAM_STR)
{
return $this->pdo->quote($string, $parameter_type);
}
public function reconnect()
{
return $this->pdo = new PDONative($this->dsn, $this->username, $this->passwd, $this->options);
}
}