1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-13 01:24:06 +02:00

added new Nette exceptions

This commit is contained in:
David Grudl
2008-02-01 02:12:36 +00:00
parent 89dfa9f772
commit 8da9e778a6
22 changed files with 473 additions and 352 deletions

View File

@@ -19,7 +19,7 @@
/**
* The dibi driver for MS SQL database
* The dibi driver for MS SQL database.
*
* Connection options:
* - 'host' - the MS SQL server host name. It can also include a port number (hostname:port)
@@ -38,14 +38,14 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
{
/**
* Connection resource
* Connection resource.
* @var resource
*/
private $connection;
/**
* Resultset resource
* Resultset resource.
* @var resource
*/
private $resultset;
@@ -58,14 +58,14 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
public function __construct()
{
if (!extension_loaded('mssql')) {
throw new DibiDriverException("PHP extension 'mssql' is not loaded");
throw new DibiDriverException("PHP extension 'mssql' is not loaded.");
}
}
/**
* Connects to a database
* Connects to a database.
*
* @return void
* @throws DibiException
@@ -83,18 +83,18 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
}
if (!is_resource($this->connection)) {
throw new DibiDriverException("Can't connect to DB");
throw new DibiDriverException("Can't connect to DB.");
}
if (isset($config['database']) && !@mssql_select_db($config['database'], $this->connection)) {
throw new DibiDriverException("Can't select DB '$config[database]'");
throw new DibiDriverException("Can't select DB '$config[database]'.");
}
}
/**
* Disconnects from a database
* Disconnects from a database.
*
* @return void
*/
@@ -106,7 +106,7 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
/**
* Executes the SQL query
* Executes the SQL query.
*
* @param string SQL statement.
* @return bool have resultset?
@@ -126,7 +126,7 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
*
* @return int|FALSE number of rows or FALSE on error
*/
@@ -138,13 +138,13 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
*
* @return int|FALSE int on success or FALSE on failure
*/
public function insertId($sequence)
{
throw new BadMethodCallException(__METHOD__ . ' is not implemented');
throw new NotSupportedException('MS SQL does not support autoincrementing.');
}
@@ -186,7 +186,7 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
/**
* Format to SQL command
* Format to SQL command.
*
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, dibi::FIELD_DATE, dibi::FIELD_DATETIME, dibi::IDENTIFIER)
@@ -200,13 +200,13 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
if ($type === dibi::FIELD_BOOL) return $value ? -1 : 0;
if ($type === dibi::FIELD_DATE) return date("'Y-m-d'", $value);
if ($type === dibi::FIELD_DATETIME) return date("'Y-m-d H:i:s'", $value);
throw new InvalidArgumentException('Unsupported formatting type');
throw new InvalidArgumentException('Unsupported formatting 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 int $limit
@@ -221,14 +221,14 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
}
if ($offset) {
throw new InvalidArgumentException('Offset is not implemented');
throw new NotImplementedException('Offset is not implemented.');
}
}
/**
* Returns the number of rows in a result set
* Returns the number of rows in a result set.
*
* @return int
*/
@@ -240,7 +240,7 @@ class DibiMsSqlDriver extends NObject 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.
* internal usage only
*
* @param bool TRUE for associative array, FALSE for numeric
@@ -254,7 +254,7 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
/**
* Moves cursor position without fetching row
* Moves cursor position without fetching row.
*
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
@@ -268,7 +268,7 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
/**
* Frees the resources allocated for this result set
* Frees the resources allocated for this result set.
*
* @return void
*/
@@ -281,7 +281,7 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
/**
* Returns metadata for all columns in a result set
* Returns metadata for all columns in a result set.
*
* @return array
*/
@@ -301,7 +301,7 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
/**
* Returns the connection resource
* Returns the connection resource.
*
* @return mixed
*/
@@ -313,7 +313,7 @@ class DibiMsSqlDriver extends NObject implements IDibiDriver
/**
* Returns the resultset resource
* Returns the resultset resource.
*
* @return mixed
*/

View File

@@ -19,7 +19,7 @@
/**
* The dibi driver for MySQL database
* The dibi driver for MySQL database.
*
* Connection options:
* - 'host' - the MySQL server host name
@@ -44,14 +44,14 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
{
/**
* Connection resource
* Connection resource.
* @var resource
*/
private $connection;
/**
* Resultset resource
* Resultset resource.
* @var resource
*/
private $resultset;
@@ -71,14 +71,14 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
public function __construct()
{
if (!extension_loaded('mysql')) {
throw new DibiDriverException("PHP extension 'mysql' is not loaded");
throw new DibiDriverException("PHP extension 'mysql' is not loaded.");
}
}
/**
* Connects to a database
* Connects to a database.
*
* @return void
* @throws DibiException
@@ -143,7 +143,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Disconnects from a database
* Disconnects from a database.
*
* @return void
*/
@@ -155,7 +155,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Executes the SQL query
* Executes the SQL query.
*
* @param string SQL statement.
* @return bool have resultset?
@@ -179,7 +179,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
*
* @return int|FALSE number of rows or FALSE on error
*/
@@ -191,7 +191,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
*
* @return int|FALSE int on success or FALSE on failure
*/
@@ -239,7 +239,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Format to SQL command
* Format to SQL command.
*
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, dibi::FIELD_DATE, dibi::FIELD_DATETIME, dibi::IDENTIFIER)
@@ -253,13 +253,13 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
if ($type === dibi::FIELD_BOOL) return $value ? 1 : 0;
if ($type === dibi::FIELD_DATE) return date("'Y-m-d'", $value);
if ($type === dibi::FIELD_DATETIME) return date("'Y-m-d H:i:s'", $value);
throw new InvalidArgumentException('Unsupported formatting type');
throw new InvalidArgumentException('Unsupported formatting 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 int $limit
@@ -278,14 +278,14 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Returns the number of rows in a result set
* Returns the number of rows in a result set.
*
* @return int
*/
public function rowCount()
{
if (!$this->buffered) {
throw new DibiDriverException('Row count is not available for unbuffered queries');
throw new DibiDriverException('Row count is not available for unbuffered queries.');
}
return mysql_num_rows($this->resultset);
}
@@ -293,7 +293,7 @@ class DibiMySqlDriver extends NObject 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.
* internal usage only
*
* @param bool TRUE for associative array, FALSE for numeric
@@ -307,7 +307,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Moves cursor position without fetching row
* Moves cursor position without fetching row.
*
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
@@ -316,7 +316,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
public function seek($row)
{
if (!$this->buffered) {
throw new DibiDriverException('Cannot seek an unbuffered result set');
throw new DibiDriverException('Cannot seek an unbuffered result set.');
}
return mysql_data_seek($this->resultset, $row);
@@ -325,7 +325,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Frees the resources allocated for this result set
* Frees the resources allocated for this result set.
*
* @return void
*/
@@ -338,7 +338,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Returns metadata for all columns in a result set
* Returns metadata for all columns in a result set.
*
* @return array
*/
@@ -356,7 +356,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Converts database error to DibiDriverException
* Converts database error to DibiDriverException.
*
* @throws DibiDriverException
*/
@@ -368,7 +368,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Returns the connection resource
* Returns the connection resource.
*
* @return mixed
*/
@@ -380,7 +380,7 @@ class DibiMySqlDriver extends NObject implements IDibiDriver
/**
* Returns the resultset resource
* Returns the resultset resource.
*
* @return mixed
*/

View File

@@ -19,7 +19,7 @@
/**
* The dibi driver for MySQL database via improved extension
* The dibi driver for MySQL database via improved extension.
*
* Connection options:
* - 'host' - the MySQL server host name
@@ -44,14 +44,14 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
{
/**
* Connection resource
* Connection resource.
* @var mysqli
*/
private $connection;
/**
* Resultset resource
* Resultset resource.
* @var mysqli_result
*/
private $resultset;
@@ -71,14 +71,14 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
public function __construct()
{
if (!extension_loaded('mysqli')) {
throw new DibiDriverException("PHP extension 'mysqli' is not loaded");
throw new DibiDriverException("PHP extension 'mysqli' is not loaded.");
}
}
/**
* Connects to a database
* Connects to a database.
*
* @return void
* @throws DibiException
@@ -127,7 +127,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Disconnects from a database
* Disconnects from a database.
*
* @return void
*/
@@ -139,7 +139,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Executes the SQL query
* Executes the SQL query.
*
* @param string SQL statement.
* @return bool have resultset?
@@ -159,7 +159,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
*
* @return int|FALSE number of rows or FALSE on error
*/
@@ -171,7 +171,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
*
* @return int|FALSE int on success or FALSE on failure
*/
@@ -219,7 +219,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Format to SQL command
* Format to SQL command.
*
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, dibi::FIELD_DATE, dibi::FIELD_DATETIME, dibi::IDENTIFIER)
@@ -233,13 +233,13 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
if ($type === dibi::FIELD_BOOL) return $value ? 1 : 0;
if ($type === dibi::FIELD_DATE) return date("'Y-m-d'", $value);
if ($type === dibi::FIELD_DATETIME) return date("'Y-m-d H:i:s'", $value);
throw new InvalidArgumentException('Unsupported formatting type');
throw new InvalidArgumentException('Unsupported formatting 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 int $limit
@@ -258,14 +258,14 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Returns the number of rows in a result set
* Returns the number of rows in a result set.
*
* @return int
*/
public function rowCount()
{
if (!$this->buffered) {
throw new DibiDriverException('Row count is not available for unbuffered queries');
throw new DibiDriverException('Row count is not available for unbuffered queries.');
}
return mysqli_num_rows($this->resultset);
}
@@ -273,7 +273,7 @@ class DibiMySqliDriver extends NObject 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.
* internal usage only
*
* @param bool TRUE for associative array, FALSE for numeric
@@ -287,7 +287,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Moves cursor position without fetching row
* Moves cursor position without fetching row.
*
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
@@ -296,7 +296,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
public function seek($row)
{
if (!$this->buffered) {
throw new DibiDriverException('Cannot seek an unbuffered result set');
throw new DibiDriverException('Cannot seek an unbuffered result set.');
}
return mysqli_data_seek($this->resultset, $row);
}
@@ -304,7 +304,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Frees the resources allocated for this result set
* Frees the resources allocated for this result set.
*
* @return void
*/
@@ -317,7 +317,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Returns metadata for all columns in a result set
* Returns metadata for all columns in a result set.
*
* @return array
*/
@@ -335,7 +335,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Converts database error to DibiDriverException
* Converts database error to DibiDriverException.
*
* @throws DibiDriverException
*/
@@ -347,7 +347,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Returns the connection resource
* Returns the connection resource.
*
* @return mysqli
*/
@@ -359,7 +359,7 @@ class DibiMySqliDriver extends NObject implements IDibiDriver
/**
* Returns the resultset resource
* Returns the resultset resource.
*
* @return mysqli_result
*/

View File

@@ -19,7 +19,7 @@
/**
* The dibi driver interacting with databases via ODBC connections
* The dibi driver interacting with databases via ODBC connections.
*
* Connection options:
* - 'dsn' - driver specific DSN
@@ -37,21 +37,21 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
{
/**
* Connection resource
* Connection resource.
* @var resource
*/
private $connection;
/**
* Resultset resource
* Resultset resource.
* @var resource
*/
private $resultset;
/**
* Cursor
* Cursor.
* @var int
*/
private $row = 0;
@@ -64,14 +64,14 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
public function __construct()
{
if (!extension_loaded('odbc')) {
throw new DibiDriverException("PHP extension 'odbc' is not loaded");
throw new DibiDriverException("PHP extension 'odbc' is not loaded.");
}
}
/**
* Connects to a database
* Connects to a database.
*
* @return void
* @throws DibiException
@@ -100,7 +100,7 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
/**
* Disconnects from a database
* Disconnects from a database.
*
* @return void
*/
@@ -112,7 +112,7 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
/**
* Executes the SQL query
* Executes the SQL query.
*
* @param string SQL statement.
* @return bool have resultset?
@@ -132,7 +132,7 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
*
* @return int|FALSE number of rows or FALSE on error
*/
@@ -144,13 +144,13 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
*
* @return int|FALSE int on success or FALSE on failure
*/
public function insertId($sequence)
{
throw new BadMethodCallException(__METHOD__ . ' is not implemented');
throw new NotSupportedException('ODBC does not support autoincrementing.');
}
@@ -200,7 +200,7 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
/**
* Format to SQL command
* Format to SQL command.
*
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, dibi::FIELD_DATE, dibi::FIELD_DATETIME, dibi::IDENTIFIER)
@@ -214,13 +214,13 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
if ($type === dibi::FIELD_BOOL) return $value ? -1 : 0;
if ($type === dibi::FIELD_DATE) return date("#m/d/Y#", $value);
if ($type === dibi::FIELD_DATETIME) return date("#m/d/Y H:i:s#", $value);
throw new InvalidArgumentException('Unsupported formatting type');
throw new InvalidArgumentException('Unsupported formatting 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 int $limit
@@ -234,13 +234,13 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
}
if ($offset) throw new InvalidArgumentException('Offset is not implemented in driver odbc');
if ($offset) throw new InvalidArgumentException('Offset is not implemented in driver odbc.');
}
/**
* Returns the number of rows in a result set
* Returns the number of rows in a result set.
*
* @return int
*/
@@ -253,7 +253,7 @@ class DibiOdbcDriver extends NObject 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.
* internal usage only
*
* @param bool TRUE for associative array, FALSE for numeric
@@ -276,7 +276,7 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
/**
* Moves cursor position without fetching row
* Moves cursor position without fetching row.
*
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
@@ -291,7 +291,7 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
/**
* Frees the resources allocated for this result set
* Frees the resources allocated for this result set.
*
* @return void
*/
@@ -304,7 +304,7 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
/**
* Returns metadata for all columns in a result set
* Returns metadata for all columns in a result set.
*
* @return array
*/
@@ -329,7 +329,7 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
/**
* Converts database error to DibiDriverException
* Converts database error to DibiDriverException.
*
* @throws DibiDriverException
*/
@@ -341,7 +341,7 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
/**
* Returns the connection resource
* Returns the connection resource.
*
* @return mixed
*/
@@ -353,7 +353,7 @@ class DibiOdbcDriver extends NObject implements IDibiDriver
/**
* Returns the resultset resource
* Returns the resultset resource.
*
* @return mixed
*/

View File

@@ -19,7 +19,7 @@
/**
* The dibi driver for Oracle database
* The dibi driver for Oracle database.
*
* Connection options:
* - 'database' (or 'db') - the name of the local Oracle instance or the name of the entry in tnsnames.ora
@@ -37,14 +37,14 @@ class DibiOracleDriver extends NObject implements IDibiDriver
{
/**
* Connection resource
* Connection resource.
* @var resource
*/
private $connection;
/**
* Resultset resource
* Resultset resource.
* @var resource
*/
private $resultset;
@@ -63,14 +63,14 @@ class DibiOracleDriver extends NObject implements IDibiDriver
public function __construct()
{
if (!extension_loaded('oci8')) {
throw new DibiDriverException("PHP extension 'oci8' is not loaded");
throw new DibiDriverException("PHP extension 'oci8' is not loaded.");
}
}
/**
* Connects to a database
* Connects to a database.
*
* @return void
* @throws DibiException
@@ -93,7 +93,7 @@ class DibiOracleDriver extends NObject implements IDibiDriver
/**
* Disconnects from a database
* Disconnects from a database.
*
* @return void
*/
@@ -105,7 +105,7 @@ class DibiOracleDriver extends NObject implements IDibiDriver
/**
* Executes the SQL query
* Executes the SQL query.
*
* @param string SQL statement.
* @return bool have resultset?
@@ -131,25 +131,25 @@ class DibiOracleDriver extends NObject implements IDibiDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
*
* @return int|FALSE number of rows or FALSE on error
*/
public function affectedRows()
{
throw new BadMethodCallException(__METHOD__ . ' is not implemented');
throw new NotImplementedException;
}
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
*
* @return int|FALSE int on success or FALSE on failure
*/
public function insertId($sequence)
{
throw new BadMethodCallException(__METHOD__ . ' is not implemented');
throw new NotSupportedException('Oracle does not support autoincrementing.');
}
@@ -197,7 +197,7 @@ class DibiOracleDriver extends NObject implements IDibiDriver
/**
* Format to SQL command
* Format to SQL command.
*
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, dibi::FIELD_DATE, dibi::FIELD_DATETIME, dibi::IDENTIFIER)
@@ -211,13 +211,13 @@ class DibiOracleDriver extends NObject implements IDibiDriver
if ($type === dibi::FIELD_BOOL) return $value ? 1 : 0;
if ($type === dibi::FIELD_DATE) return date("U", $value);
if ($type === dibi::FIELD_DATETIME) return date("U", $value);
throw new InvalidArgumentException('Unsupported formatting type');
throw new InvalidArgumentException('Unsupported formatting 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 int $limit
@@ -233,7 +233,7 @@ class DibiOracleDriver extends NObject implements IDibiDriver
/**
* Returns the number of rows in a result set
* Returns the number of rows in a result set.
*
* @return int
*/
@@ -245,7 +245,7 @@ class DibiOracleDriver extends NObject 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.
* internal usage only
*
* @param bool TRUE for associative array, FALSE for numeric
@@ -259,7 +259,7 @@ class DibiOracleDriver extends NObject implements IDibiDriver
/**
* Moves cursor position without fetching row
* Moves cursor position without fetching row.
*
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
@@ -267,13 +267,13 @@ class DibiOracleDriver extends NObject implements IDibiDriver
*/
public function seek($row)
{
throw new BadMethodCallException(__METHOD__ . ' is not implemented');
throw new NotImplementedException;
}
/**
* Frees the resources allocated for this result set
* Frees the resources allocated for this result set.
*
* @return void
*/
@@ -286,7 +286,7 @@ class DibiOracleDriver extends NObject implements IDibiDriver
/**
* Returns metadata for all columns in a result set
* Returns metadata for all columns in a result set.
*
* @return array
*/
@@ -311,7 +311,7 @@ class DibiOracleDriver extends NObject implements IDibiDriver
/**
* Converts database error to DibiDriverException
* Converts database error to DibiDriverException.
*
* @throws DibiDriverException
*/
@@ -324,7 +324,7 @@ class DibiOracleDriver extends NObject implements IDibiDriver
/**
* Returns the connection resource
* Returns the connection resource.
*
* @return mixed
*/
@@ -336,7 +336,7 @@ class DibiOracleDriver extends NObject implements IDibiDriver
/**
* Returns the resultset resource
* Returns the resultset resource.
*
* @return mixed
*/

View File

@@ -19,7 +19,7 @@
/**
* The dibi driver for PDO
* The dibi driver for PDO.
*
* Connection options:
* - 'dsn' - driver specific DSN
@@ -37,21 +37,21 @@ class DibiPdoDriver extends NObject implements IDibiDriver
{
/**
* Connection resource
* Connection resource.
* @var PDO
*/
private $connection;
/**
* Resultset resource
* Resultset resource.
* @var PDOStatement
*/
private $resultset;
/**
* Affected rows
* Affected rows.
* @var int
*/
private $affectedRows = FALSE;
@@ -64,14 +64,14 @@ class DibiPdoDriver extends NObject implements IDibiDriver
public function __construct()
{
if (!extension_loaded('pdo')) {
throw new DibiDriverException("PHP extension 'pdo' is not loaded");
throw new DibiDriverException("PHP extension 'pdo' is not loaded.");
}
}
/**
* Connects to a database
* Connects to a database.
*
* @return void
* @throws DibiException
@@ -90,14 +90,14 @@ class DibiPdoDriver extends NObject implements IDibiDriver
}
if (!$this->connection) {
throw new DibiDriverException('Connecting error');
throw new DibiDriverException('Connecting error.');
}
}
/**
* Disconnects from a database
* Disconnects from a database.
*
* @return void
*/
@@ -109,7 +109,7 @@ class DibiPdoDriver extends NObject implements IDibiDriver
/**
* Executes the SQL query
* Executes the SQL query.
*
* @param string SQL statement.
* @return bool have resultset?
@@ -146,7 +146,7 @@ class DibiPdoDriver extends NObject implements IDibiDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
*
* @return int|FALSE number of rows or FALSE on error
*/
@@ -158,7 +158,7 @@ class DibiPdoDriver extends NObject implements IDibiDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
*
* @return int|FALSE int on success or FALSE on failure
*/
@@ -212,7 +212,7 @@ class DibiPdoDriver extends NObject implements IDibiDriver
/**
* Format to SQL command
* Format to SQL command.
*
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, dibi::FIELD_DATE, dibi::FIELD_DATETIME, dibi::IDENTIFIER)
@@ -226,13 +226,13 @@ class DibiPdoDriver extends NObject implements IDibiDriver
if ($type === dibi::FIELD_BOOL) return $value ? 1 : 0;
if ($type === dibi::FIELD_DATE) return date("'Y-m-d'", $value);
if ($type === dibi::FIELD_DATETIME) return date("'Y-m-d H:i:s'", $value);
throw new InvalidArgumentException('Unsupported formatting type');
throw new InvalidArgumentException('Unsupported formatting 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 int $limit
@@ -241,25 +241,25 @@ class DibiPdoDriver extends NObject implements IDibiDriver
*/
public function applyLimit(&$sql, $limit, $offset)
{
throw new BadMethodCallException(__METHOD__ . ' is not implemented');
throw new NotSupportedException('PDO does not support applying limit or offset.');
}
/**
* Returns the number of rows in a result set
* Returns the number of rows in a result set.
*
* @return int
*/
public function rowCount()
{
throw new DibiDriverException('Row count is not available for unbuffered queries');
throw new DibiDriverException('Row count is not available for unbuffered queries.');
}
/**
* 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.
* internal usage only
*
* @param bool TRUE for associative array, FALSE for numeric
@@ -273,7 +273,7 @@ class DibiPdoDriver extends NObject implements IDibiDriver
/**
* Moves cursor position without fetching row
* Moves cursor position without fetching row.
*
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
@@ -281,13 +281,13 @@ class DibiPdoDriver extends NObject implements IDibiDriver
*/
public function seek($row)
{
throw new DibiDriverException('Cannot seek an unbuffered result set');
throw new DibiDriverException('Cannot seek an unbuffered result set.');
}
/**
* Frees the resources allocated for this result set
* Frees the resources allocated for this result set.
*
* @return void
*/
@@ -299,7 +299,7 @@ class DibiPdoDriver extends NObject implements IDibiDriver
/**
* Returns metadata for all columns in a result set
* Returns metadata for all columns in a result set.
*
* @return array
* @throws DibiException
@@ -312,7 +312,7 @@ class DibiPdoDriver extends NObject implements IDibiDriver
// items 'name' and 'table' are required
$info = @$this->resultset->getColumnsMeta($i);
if ($info === FALSE) {
throw new DibiDriverException('Driver does not support meta data');
throw new DibiDriverException('Driver does not support meta data.');
}
$meta[] = $info;
}
@@ -322,7 +322,7 @@ class DibiPdoDriver extends NObject implements IDibiDriver
/**
* Converts database error to DibiDriverException
* Converts database error to DibiDriverException.
*
* @throws DibiDriverException
*/
@@ -335,7 +335,7 @@ class DibiPdoDriver extends NObject implements IDibiDriver
/**
* Returns the connection resource
* Returns the connection resource.
*
* @return PDO
*/
@@ -347,7 +347,7 @@ class DibiPdoDriver extends NObject implements IDibiDriver
/**
* Returns the resultset resource
* Returns the resultset resource.
*
* @return PDOStatement
*/

View File

@@ -19,7 +19,7 @@
/**
* The dibi driver for PostgreSQL database
* The dibi driver for PostgreSQL database.
*
* Connection options:
* - 'host','hostaddr','port','dbname','user','password','connect_timeout','options','sslmode','service' - see PostgreSQL API
@@ -37,21 +37,21 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
{
/**
* Connection resource
* Connection resource.
* @var resource
*/
private $connection;
/**
* Resultset resource
* Resultset resource.
* @var resource
*/
private $resultset;
/**
* Escape method
* Escape method.
* @var bool
*/
private $escMethod = FALSE;
@@ -64,14 +64,14 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
public function __construct()
{
if (!extension_loaded('pgsql')) {
throw new DibiDriverException("PHP extension 'pgsql' is not loaded");
throw new DibiDriverException("PHP extension 'pgsql' is not loaded.");
}
}
/**
* Connects to a database
* Connects to a database.
*
* @return void
* @throws DibiException
@@ -96,7 +96,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
DibiDriverException::restore();
if (!is_resource($this->connection)) {
throw new DibiDriverException('Connecting error');
throw new DibiDriverException('Connecting error.');
}
if (isset($config['charset'])) {
@@ -111,7 +111,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
/**
* Disconnects from a database
* Disconnects from a database.
*
* @return void
*/
@@ -123,7 +123,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
/**
* Executes the SQL query
* Executes the SQL query.
*
* @param string SQL statement.
* @param bool update affected rows?
@@ -144,7 +144,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
*
* @return int|FALSE number of rows or FALSE on error
*/
@@ -156,7 +156,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
*
* @return int|FALSE int on success or FALSE on failure
*/
@@ -215,7 +215,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
/**
* Format to SQL command
* Format to SQL command.
*
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, dibi::FIELD_DATE, dibi::FIELD_DATETIME, dibi::IDENTIFIER)
@@ -239,13 +239,13 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
if ($type === dibi::FIELD_BOOL) return $value ? 'TRUE' : 'FALSE';
if ($type === dibi::FIELD_DATE) return date("'Y-m-d'", $value);
if ($type === dibi::FIELD_DATETIME) return date("'Y-m-d H:i:s'", $value);
throw new InvalidArgumentException('Unsupported formatting type');
throw new InvalidArgumentException('Unsupported formatting 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 int $limit
@@ -264,7 +264,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
/**
* Returns the number of rows in a result set
* Returns the number of rows in a result set.
*
* @return int
*/
@@ -276,7 +276,7 @@ class DibiPostgreDriver extends NObject 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.
* internal usage only
*
* @param bool TRUE for associative array, FALSE for numeric
@@ -290,7 +290,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
/**
* Moves cursor position without fetching row
* Moves cursor position without fetching row.
*
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
@@ -304,7 +304,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
/**
* Frees the resources allocated for this result set
* Frees the resources allocated for this result set.
*
* @return void
*/
@@ -317,7 +317,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
/**
* Returns metadata for all columns in a result set
* Returns metadata for all columns in a result set.
*
* @return array
*/
@@ -342,7 +342,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
/**
* Returns the connection resource
* Returns the connection resource.
*
* @return mixed
*/
@@ -354,7 +354,7 @@ class DibiPostgreDriver extends NObject implements IDibiDriver
/**
* Returns the resultset resource
* Returns the resultset resource.
*
* @return mixed
*/

View File

@@ -19,7 +19,7 @@
/**
* The dibi driver for SQLite database
* The dibi driver for SQLite database.
*
* Connection options:
* - 'database' (or 'file') - the filename of the SQLite database
@@ -38,14 +38,14 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
{
/**
* Connection resource
* Connection resource.
* @var resource
*/
private $connection;
/**
* Resultset resource
* Resultset resource.
* @var resource
*/
private $resultset;
@@ -59,7 +59,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Date and datetime format
* Date and datetime format.
* @var string
*/
private $fmtDate, $fmtDateTime;
@@ -72,14 +72,14 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
public function __construct()
{
if (!extension_loaded('sqlite')) {
throw new DibiDriverException("PHP extension 'sqlite' is not loaded");
throw new DibiDriverException("PHP extension 'sqlite' is not loaded.");
}
}
/**
* Connects to a database
* Connects to a database.
*
* @return void
* @throws DibiException
@@ -107,7 +107,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Disconnects from a database
* Disconnects from a database.
*
* @return void
*/
@@ -119,7 +119,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Executes the SQL query
* Executes the SQL query.
*
* @param string SQL statement.
* @return bool have resultset?
@@ -141,7 +141,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
*
* @return int|FALSE number of rows or FALSE on error
*/
@@ -153,7 +153,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
*
* @return int|FALSE int on success or FALSE on failure
*/
@@ -201,7 +201,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Format to SQL command
* Format to SQL command.
*
* @param string value
* @param string type (dibi::FIELD_TEXT, dibi::FIELD_BOOL, dibi::FIELD_DATE, dibi::FIELD_DATETIME, dibi::IDENTIFIER)
@@ -215,13 +215,13 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
if ($type === dibi::FIELD_BOOL) return $value ? 1 : 0;
if ($type === dibi::FIELD_DATE) return date($this->fmtDate, $value);
if ($type === dibi::FIELD_DATETIME) return date($this->fmtDateTime, $value);
throw new InvalidArgumentException('Unsupported formatting type');
throw new InvalidArgumentException('Unsupported formatting 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 int $limit
@@ -237,14 +237,14 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Returns the number of rows in a result set
* Returns the number of rows in a result set.
*
* @return int
*/
public function rowCount()
{
if (!$this->buffered) {
throw new DibiDriverException('Row count is not available for unbuffered queries');
throw new DibiDriverException('Row count is not available for unbuffered queries.');
}
return sqlite_num_rows($this->resultset);
}
@@ -252,7 +252,7 @@ class DibiSqliteDriver extends NObject 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.
* internal usage only
*
* @param bool TRUE for associative array, FALSE for numeric
@@ -266,7 +266,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Moves cursor position without fetching row
* Moves cursor position without fetching row.
*
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
@@ -275,7 +275,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
public function seek($row)
{
if (!$this->buffered) {
throw new DibiDriverException('Cannot seek an unbuffered result set');
throw new DibiDriverException('Cannot seek an unbuffered result set.');
}
return sqlite_seek($this->resultset, $row);
}
@@ -283,7 +283,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Frees the resources allocated for this result set
* Frees the resources allocated for this result set.
*
* @return void
*/
@@ -295,7 +295,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Returns metadata for all columns in a result set
* Returns metadata for all columns in a result set.
*
* @return array
*/
@@ -316,7 +316,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Returns the connection resource
* Returns the connection resource.
*
* @return mixed
*/
@@ -328,7 +328,7 @@ class DibiSqliteDriver extends NObject implements IDibiDriver
/**
* Returns the resultset resource
* Returns the resultset resource.
*
* @return mixed
*/