class PDOWrapper extends PDO
{
// 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 __construct ( string $dsn [, string $username [, string $password [, array $options ]]] )
public function __construct($dsn, $username = null, $password = null, $options = array())
{
parent::__construct($dsn, $username, $password, $options);
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)
->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
}
// public bool setAttribute ( int $attribute , mixed $value )
public function setAttribute($attribute, $value)
{
parent::setAttribute($attribute, $value);
return $this;
}
public function run($query, $arguments = array())
{
$stmt = $this->prepare($query);
$stmt->execute($arguments);
return $stmt;
}
public function get($query, $arguments = array())
{
return $this->run($query, $arguments)->fetch();
}
public function getColumn($query, $arguments = array())
{
return $this->run($query, $arguments)->fetchColumn();
}
public function getAll($query, $arguments = array())
{
return $this->run($query, $arguments)->fetchAll();
}
}