1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-07 06:36:44 +02:00

IDibiDriver splitted into IDibiDriver & IDibiResultDriver

This commit is contained in:
David Grudl
2010-08-04 15:27:41 +02:00
parent 5cce595518
commit de85d3814e
14 changed files with 49 additions and 57 deletions

View File

@@ -27,7 +27,7 @@
* @copyright Copyright (c) 2010 * @copyright Copyright (c) 2010
* @package dibi\drivers * @package dibi\drivers
*/ */
class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiReflector class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultDriver, IDibiReflector
{ {
const ERROR_EXCEPTION_THROWN = -836; const ERROR_EXCEPTION_THROWN = -836;
@@ -109,7 +109,7 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiReflect
/** /**
* Executes the SQL query. * Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @return IDibiDriver|NULL * @return IDibiResultDriver|NULL
* @throws DibiDriverException|DibiException * @throws DibiDriverException|DibiException
*/ */
public function query($sql) public function query($sql)
@@ -331,7 +331,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiReflect
* Fetches the row at current position and moves the internal cursor to the next position. * Fetches the row at current position and moves the internal cursor to the next position.
* @param bool TRUE for associative array, FALSE for numeric * @param bool TRUE for associative array, FALSE for numeric
* @return array array on success, nonarray if no next record * @return array array on success, nonarray if no next record
* @internal
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {

View File

@@ -26,7 +26,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl * @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers * @package dibi\drivers
*/ */
class DibiMsSqlDriver extends DibiObject implements IDibiDriver class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
{ {
/** @var resource Connection resource */ /** @var resource Connection resource */
private $connection; private $connection;
@@ -88,7 +88,7 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
/** /**
* Executes the SQL query. * Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @return IDibiDriver|NULL * @return IDibiResultDriver|NULL
* @throws DibiDriverException * @throws DibiDriverException
*/ */
public function query($sql) public function query($sql)
@@ -276,7 +276,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
* Fetches the row at current position and moves the internal cursor to the next position. * Fetches the row at current position and moves the internal cursor to the next position.
* @param bool TRUE for associative array, FALSE for numeric * @param bool TRUE for associative array, FALSE for numeric
* @return array array on success, nonarray if no next record * @return array array on success, nonarray if no next record
* @internal
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {

View File

@@ -27,7 +27,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl * @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers * @package dibi\drivers
*/ */
class DibiMsSql2005Driver extends DibiObject implements IDibiDriver class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResultDriver
{ {
/** @var resource Connection resource */ /** @var resource Connection resource */
private $connection; private $connection;
@@ -89,7 +89,7 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
/** /**
* Executes the SQL query. * Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @return IDibiDriver|NULL * @return IDibiResultDriver|NULL
* @throws DibiDriverException * @throws DibiDriverException
*/ */
public function query($sql) public function query($sql)
@@ -278,7 +278,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
* Fetches the row at current position and moves the internal cursor to the next position. * Fetches the row at current position and moves the internal cursor to the next position.
* @param bool TRUE for associative array, FALSE for numeric * @param bool TRUE for associative array, FALSE for numeric
* @return array array on success, nonarray if no next record * @return array array on success, nonarray if no next record
* @internal
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {

View File

@@ -32,7 +32,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl * @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers * @package dibi\drivers
*/ */
class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiReflector class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriver, IDibiReflector
{ {
const ERROR_ACCESS_DENIED = 1045; const ERROR_ACCESS_DENIED = 1045;
const ERROR_DUPLICATE_ENTRY = 1062; const ERROR_DUPLICATE_ENTRY = 1062;
@@ -146,7 +146,7 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiReflector
/** /**
* Executes the SQL query. * Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @return IDibiDriver|NULL * @return IDibiResultDriver|NULL
* @throws DibiDriverException * @throws DibiDriverException
*/ */
public function query($sql) public function query($sql)
@@ -353,7 +353,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiReflector
* Fetches the row at current position and moves the internal cursor to the next position. * Fetches the row at current position and moves the internal cursor to the next position.
* @param bool TRUE for associative array, FALSE for numeric * @param bool TRUE for associative array, FALSE for numeric
* @return array array on success, nonarray if no next record * @return array array on success, nonarray if no next record
* @internal
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {

View File

@@ -33,7 +33,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl * @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers * @package dibi\drivers
*/ */
class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiReflector class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDriver, IDibiReflector
{ {
const ERROR_ACCESS_DENIED = 1045; const ERROR_ACCESS_DENIED = 1045;
const ERROR_DUPLICATE_ENTRY = 1062; const ERROR_DUPLICATE_ENTRY = 1062;
@@ -147,7 +147,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiReflector
/** /**
* Executes the SQL query. * Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @return IDibiDriver|NULL * @return IDibiResultDriver|NULL
* @throws DibiDriverException * @throws DibiDriverException
*/ */
public function query($sql) public function query($sql)
@@ -349,7 +349,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiReflector
* Fetches the row at current position and moves the internal cursor to the next position. * Fetches the row at current position and moves the internal cursor to the next position.
* @param bool TRUE for associative array, FALSE for numeric * @param bool TRUE for associative array, FALSE for numeric
* @return array array on success, nonarray if no next record * @return array array on success, nonarray if no next record
* @internal
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {

View File

@@ -25,7 +25,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl * @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers * @package dibi\drivers
*/ */
class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiReflector class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDriver, IDibiReflector
{ {
/** @var resource Connection resource */ /** @var resource Connection resource */
private $connection; private $connection;
@@ -93,7 +93,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiReflector
/** /**
* Executes the SQL query. * Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @return IDibiDriver|NULL * @return IDibiResultDriver|NULL
* @throws DibiDriverException * @throws DibiDriverException
*/ */
public function query($sql) public function query($sql)
@@ -293,7 +293,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiReflector
* Fetches the row at current position and moves the internal cursor to the next position. * Fetches the row at current position and moves the internal cursor to the next position.
* @param bool TRUE for associative array, FALSE for numeric * @param bool TRUE for associative array, FALSE for numeric
* @return array array on success, nonarray if no next record * @return array array on success, nonarray if no next record
* @internal
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {

View File

@@ -27,7 +27,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl * @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers * @package dibi\drivers
*/ */
class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiReflector class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDriver, IDibiReflector
{ {
/** @var resource Connection resource */ /** @var resource Connection resource */
private $connection; private $connection;
@@ -94,7 +94,7 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiReflector
/** /**
* Executes the SQL query. * Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @return IDibiDriver|NULL * @return IDibiResultDriver|NULL
* @throws DibiDriverException * @throws DibiDriverException
*/ */
public function query($sql) public function query($sql)
@@ -291,7 +291,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiReflector
* Fetches the row at current position and moves the internal cursor to the next position. * Fetches the row at current position and moves the internal cursor to the next position.
* @param bool TRUE for associative array, FALSE for numeric * @param bool TRUE for associative array, FALSE for numeric
* @return array array on success, nonarray if no next record * @return array array on success, nonarray if no next record
* @internal
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {

View File

@@ -25,7 +25,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl * @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers * @package dibi\drivers
*/ */
class DibiPdoDriver extends DibiObject implements IDibiDriver class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
{ {
/** @var PDO Connection resource */ /** @var PDO Connection resource */
private $connection; private $connection;
@@ -97,7 +97,7 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
/** /**
* Executes the SQL query. * Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @return IDibiDriver|NULL * @return IDibiResultDriver|NULL
* @throws DibiDriverException * @throws DibiDriverException
*/ */
public function query($sql) public function query($sql)
@@ -356,7 +356,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
* Fetches the row at current position and moves the internal cursor to the next position. * Fetches the row at current position and moves the internal cursor to the next position.
* @param bool TRUE for associative array, FALSE for numeric * @param bool TRUE for associative array, FALSE for numeric
* @return array array on success, nonarray if no next record * @return array array on success, nonarray if no next record
* @internal
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {

View File

@@ -26,7 +26,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl * @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers * @package dibi\drivers
*/ */
class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiReflector class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDriver, IDibiReflector
{ {
/** @var resource Connection resource */ /** @var resource Connection resource */
private $connection; private $connection;
@@ -119,8 +119,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiReflecto
/** /**
* Executes the SQL query. * Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @param bool update affected rows? * @return IDibiResultDriver|NULL
* @return IDibiDriver|NULL
* @throws DibiDriverException * @throws DibiDriverException
*/ */
public function query($sql) public function query($sql)
@@ -332,7 +331,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiReflecto
* Fetches the row at current position and moves the internal cursor to the next position. * Fetches the row at current position and moves the internal cursor to the next position.
* @param bool TRUE for associative array, FALSE for numeric * @param bool TRUE for associative array, FALSE for numeric
* @return array array on success, nonarray if no next record * @return array array on success, nonarray if no next record
* @internal
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {

View File

@@ -28,7 +28,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl * @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers * @package dibi\drivers
*/ */
class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiReflector class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDriver, IDibiReflector
{ {
/** @var resource Connection resource */ /** @var resource Connection resource */
private $connection; private $connection;
@@ -108,7 +108,7 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiReflector
/** /**
* Executes the SQL query. * Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @return IDibiDriver|NULL * @return IDibiResultDriver|NULL
* @throws DibiDriverException * @throws DibiDriverException
*/ */
public function query($sql) public function query($sql)
@@ -295,7 +295,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiReflector
* Fetches the row at current position and moves the internal cursor to the next position. * Fetches the row at current position and moves the internal cursor to the next position.
* @param bool TRUE for associative array, FALSE for numeric * @param bool TRUE for associative array, FALSE for numeric
* @return array array on success, nonarray if no next record * @return array array on success, nonarray if no next record
* @internal
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {

View File

@@ -26,7 +26,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl * @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers * @package dibi\drivers
*/ */
class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiReflector class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDriver, IDibiReflector
{ {
/** @var SQLite3 Connection resource */ /** @var SQLite3 Connection resource */
private $connection; private $connection;
@@ -103,7 +103,7 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiReflecto
/** /**
* Executes the SQL query. * Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @return IDibiDriver|NULL * @return IDibiResultDriver|NULL
* @throws DibiDriverException * @throws DibiDriverException
*/ */
public function query($sql) public function query($sql)
@@ -285,7 +285,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiReflecto
* Fetches the row at current position and moves the internal cursor to the next position. * Fetches the row at current position and moves the internal cursor to the next position.
* @param bool TRUE for associative array, FALSE for numeric * @param bool TRUE for associative array, FALSE for numeric
* @return array array on success, nonarray if no next record * @return array array on success, nonarray if no next record
* @internal
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {

View File

@@ -349,7 +349,7 @@ class DibiTableInfo extends DibiObject
*/ */
class DibiResultInfo extends DibiObject class DibiResultInfo extends DibiObject
{ {
/** @var IDibiReflector */ /** @var IDibiResultDriver */
private $driver; private $driver;
/** @var array */ /** @var array */
@@ -360,7 +360,7 @@ class DibiResultInfo extends DibiObject
public function __construct(IDibiReflector $driver) public function __construct(IDibiResultDriver $driver)
{ {
$this->driver = $driver; $this->driver = $driver;
} }

View File

@@ -32,7 +32,7 @@
* @package dibi * @package dibi
* *
* @property-read mixed $resource * @property-read mixed $resource
* @property-read IDibiDriver $driver * @property-read IDibiResultDriver $driver
* @property-read int $rowCount * @property-read int $rowCount
* @property-read DibiResultIterator $iterator * @property-read DibiResultIterator $iterator
* @property string $rowClass * @property string $rowClass
@@ -40,7 +40,7 @@
*/ */
class DibiResult extends DibiObject implements IDataSource class DibiResult extends DibiObject implements IDataSource
{ {
/** @var array IDibiDriver */ /** @var array IDibiResultDriver */
private $driver; private $driver;
/** @var array Translate table */ /** @var array Translate table */
@@ -61,7 +61,7 @@ class DibiResult extends DibiObject implements IDataSource
/** /**
* @param IDibiDriver * @param IDibiResultDriver
* @param array * @param array
*/ */
public function __construct($driver, $config) public function __construct($driver, $config)
@@ -106,7 +106,7 @@ class DibiResult extends DibiObject implements IDataSource
/** /**
* Safe access to property $driver. * Safe access to property $driver.
* @return IDibiDriver * @return IDibiResultDriver
* @throws InvalidStateException * @throws InvalidStateException
*/ */
private function getDriver() private function getDriver()

View File

@@ -104,7 +104,7 @@ interface IDibiDriver
/** /**
* Internal: Executes the SQL query. * Internal: Executes the SQL query.
* @param string SQL statement. * @param string SQL statement.
* @return IDibiDriver|NULL * @return IDibiResultDriver|NULL
* @throws DibiDriverException * @throws DibiDriverException
*/ */
function query($sql); function query($sql);
@@ -151,12 +151,6 @@ interface IDibiDriver
*/ */
function getResource(); function getResource();
/********************* SQL ****************d*g**/
/** /**
* Encodes data for use in a SQL statement. * Encodes data for use in a SQL statement.
* @param string value * @param string value
@@ -166,15 +160,6 @@ interface IDibiDriver
*/ */
function escape($value, $type); function escape($value, $type);
/**
* Decodes data from result set.
* @param string value
* @param string type (dibi::BINARY)
* @return string decoded value
* @throws InvalidArgumentException
*/
function unescape($value, $type);
/** /**
* Injects LIMIT/OFFSET to the SQL query. * Injects LIMIT/OFFSET to the SQL query.
* @param string &$sql The SQL query that will be modified. * @param string &$sql The SQL query that will be modified.
@@ -184,12 +169,21 @@ interface IDibiDriver
*/ */
function applyLimit(&$sql, $limit, $offset); function applyLimit(&$sql, $limit, $offset);
}
/********************* result set ****************d*g**/
/**
* dibi result set driver interface.
*
* @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi
*/
interface IDibiResultDriver
{
/** /**
* Returns the number of rows in a result set. * Returns the number of rows in a result set.
* @return int * @return int
@@ -230,6 +224,16 @@ interface IDibiDriver
* @return mixed * @return mixed
*/ */
function getResultResource(); function getResultResource();
/**
* Decodes data from result set.
* @param string value
* @param string type (dibi::BINARY)
* @return string decoded value
* @throws InvalidArgumentException
*/
function unescape($value, $type);
} }