class PDOWrapper extends PDO
{
// public __construct ( string $dsn [, string $username [, string $password [, array $options ]]] )
// public mixed errorCode ( void )
// public array errorInfo ( void )
// public int exec ( string $statement )
// public mixed getAttribute ( int $attribute )
// static array getAvailableDrivers ( void )
// public string lastInsertId ([ string $name = NULL ] )
// public string quote ( string $string [, int $parameter_type = PDO::PARAM_STR ] )
// public bool inTransaction ( void )
/*
// public bool beginTransaction ( void )
public function beginTransaction()
{
parent::beginTransaction();
return $this;
}
// public bool commit ( void )
public function commit()
{
parent::commit();
return $this;
}
// public bool rollBack ( void )
public function rollBack()
{
parent::rollBack();
return $this;
}
*/
// public bool setAttribute ( int $attribute , mixed $value )
public function setAttribute($attribute, $value)
{
parent::setAttribute($attribute, $value);
return $this;
}
// public PDOStatement prepare ( string $statement [, array $driver_options = array() ] )
public function prepare($statement, $driver_options = array())
{
return new PDOStatementWrapper(parent::prepare($statement, $driver_options));
}
// public PDOStatement query ( string $statement )
public function query($statement)
{
return new PDOStatementWrapper(parent::query($statement));
}
}
class PDOStatementWrapper
{
private $stmt;
private $callMap = array(
'bindColumn' => true,
'bindParam' => true,
'bindValue' => true,
'execute' => true,
'setAttribute' => true,
'setFetchMode' => true,
);
public function __construct(PDOStatement $PDOStatement)
{
$this->stmt = $PDOStatement;
}
// Property redirector.
public function __get($name)
{
return $this->stmt->$name;
}
public function __set($name, $value)
{
$this->stmt->$name = $value;
}
// public bool closeCursor ( void )
// public int columnCount ( void )
// public void debugDumpParams ( void )
// public string errorCode ( void )
// public array errorInfo ( void )
// public mixed fetch ([ int $fetch_style [, int $cursor_orientation = PDO::FETCH_ORI_NEXT [, int $cursor_offset = 0 ]]] )
// public array fetchAll ([ int $fetch_style [, mixed $fetch_argument [, array $ctor_args = array() ]]] )
// public string fetchColumn ([ int $column_number = 0 ] )
// public mixed fetchObject ([ string $class_name = "stdClass" [, array $ctor_args ]] )
// public mixed getAttribute ( int $attribute )
// public array getColumnMeta ( int $column )
// public bool nextRowset ( void )
// public int rowCount ( void )
public function __call($name, $arguments)
{
$result = call_user_func_array(array($this->stmt, $name), $arguments);
return isset($this->callMap[$name]) ? $this : $result;
}
// public bool bindColumn ( mixed $column , mixed &$param [, int $type [, int $maxlen [, mixed $driverdata ]]] )
public function bindColumn($column, &$param)
{
return $this->__call(__FUNCTION__, func_get_args());
}
// public bool bindParam ( mixed $parameter , mixed &$variable [, int $data_type = PDO::PARAM_STR [, int $length [, mixed $driver_options ]]] )
public function bindParam($parameter, &$variable)
{
return $this->__call(__FUNCTION__, func_get_args());
}
// public bool bindValue ( mixed $parameter , mixed $value [, int $data_type = PDO::PARAM_STR ] )
// public bool execute ([ array $input_parameters ] )
// public bool setAttribute ( int $attribute , mixed $value )
// public bool setFetchMode ( int $mode )
}