From 8da9e778a69eb5e74256b00f35924d4333266268 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 1 Feb 2008 02:12:36 +0000 Subject: [PATCH] added new Nette exceptions --- dibi/{libs => Nette}/NException.php | 16 ++-- dibi/{libs => Nette}/NObject.php | 32 ++++---- dibi/Nette/exceptions.php | 119 ++++++++++++++++++++++++++++ dibi/dibi.php | 85 ++++++++++---------- dibi/drivers/mssql.php | 46 +++++------ dibi/drivers/mysql.php | 44 +++++----- dibi/drivers/mysqli.php | 44 +++++----- dibi/drivers/odbc.php | 46 +++++------ dibi/drivers/oracle.php | 46 +++++------ dibi/drivers/pdo.php | 52 ++++++------ dibi/drivers/postgre.php | 42 +++++----- dibi/drivers/sqlite.php | 44 +++++----- dibi/libs/DibiConnection.php | 57 ++++++------- dibi/libs/DibiDataSource.php | 2 +- dibi/libs/DibiException.php | 6 +- dibi/libs/DibiLogger.php | 4 +- dibi/libs/DibiResult.php | 52 ++++++------ dibi/libs/DibiResultIterator.php | 6 +- dibi/libs/DibiTable.php | 30 +++---- dibi/libs/DibiTranslator.php | 14 ++-- dibi/libs/DibiVariable.php | 2 +- dibi/libs/interfaces.php | 36 ++++----- 22 files changed, 473 insertions(+), 352 deletions(-) rename dibi/{libs => Nette}/NException.php (85%) rename dibi/{libs => Nette}/NObject.php (82%) create mode 100644 dibi/Nette/exceptions.php diff --git a/dibi/libs/NException.php b/dibi/Nette/NException.php similarity index 85% rename from dibi/libs/NException.php rename to dibi/Nette/NException.php index 6c846971..89b65d20 100644 --- a/dibi/libs/NException.php +++ b/dibi/Nette/NException.php @@ -21,7 +21,7 @@ /** - * Nette Exception base class + * Nette Exception base class. * * @author David Grudl * @copyright Copyright (c) 2004, 2008 David Grudl @@ -44,7 +44,7 @@ class NException extends Exception /** - * Initializes the cause of this throwable to the specified value + * Initializes the cause of this throwable to the specified value. * * @param Exception * @return void @@ -54,14 +54,14 @@ class NException extends Exception if ($this->cause === NULL) { $this->cause = $cause; } else { - throw new BadMethodCallException('Cause was already assigned'); + throw new InvalidStateException('Cause was already assigned.'); } } /** - * Gets the Exception instance that caused the current exception + * Gets the Exception instance that caused the current exception. * * @return Exception */ @@ -73,7 +73,7 @@ class NException extends Exception /** - * Returns string represenation of exception + * Returns string represenation of exception. * * @return string */ @@ -85,7 +85,7 @@ class NException extends Exception /** - * Enables converting all PHP errors to exceptions + * Enables converting all PHP errors to exceptions. * * @param Exception class to be thrown * @return void @@ -99,7 +99,7 @@ class NException extends Exception /** - * Disables converting errors to exceptions + * Disables converting errors to exceptions. * * @return void */ @@ -116,7 +116,7 @@ class NException extends Exception /** - * Internal error handler + * Internal error handler. */ public static function _errorHandler($code, $message, $file, $line, $context) { diff --git a/dibi/libs/NObject.php b/dibi/Nette/NObject.php similarity index 82% rename from dibi/libs/NObject.php rename to dibi/Nette/NObject.php index 2d8578f5..d61850b7 100644 --- a/dibi/libs/NObject.php +++ b/dibi/Nette/NObject.php @@ -66,7 +66,7 @@ abstract class NObject { /** - * Returns the name of the class of this object + * Returns the name of the class of this object. * * @return string */ @@ -78,7 +78,7 @@ abstract class NObject /** - * Access to reflection + * Access to reflection. * * @return ReflectionObject */ @@ -90,17 +90,17 @@ abstract class NObject /** - * Call to undefined method + * Call to undefined method. * * @param string method name * @param array arguments * @return mixed - * @throws BadMethodCallException + * @throws MemberAccessException */ protected function __call($name, $args) { if ($name === '') { - throw new BadMethodCallException("Call to method without name"); + throw new MemberAccessException("Call to method without name."); } $class = get_class($this); @@ -126,7 +126,7 @@ abstract class NObject } } while ($cl = get_parent_class($cl)); - throw new BadMethodCallException("Call to undefined method $class::$name()"); + throw new MemberAccessException("Call to undefined method $class::$name()."); } @@ -136,12 +136,12 @@ abstract class NObject * * @param string property name * @return mixed property value - * @throws LogicException if the property is not defined. + * @throws MemberAccessException if the property is not defined. */ protected function &__get($name) { if ($name === '') { - throw new LogicException("Cannot read an property without name"); + throw new MemberAccessException("Cannot read an property without name."); } // property getter support @@ -155,7 +155,7 @@ abstract class NObject return $val; } else { - throw new LogicException("Cannot read an undeclared property $class::\$$name"); + throw new MemberAccessException("Cannot read an undeclared property $class::\$$name."); } } @@ -167,12 +167,12 @@ abstract class NObject * @param string property name * @param mixed property value * @return void - * @throws LogicException if the property is not defined or is read-only + * @throws MemberAccessException if the property is not defined or is read-only */ protected function __set($name, $value) { if ($name === '') { - throw new LogicException('Cannot assign to an property without name'); + throw new MemberAccessException('Cannot assign to an property without name.'); } // property setter support @@ -183,11 +183,11 @@ abstract class NObject $this->$m($value); } else { - throw new LogicException("Cannot assign to a read-only property $class::\$$name"); + throw new MemberAccessException("Cannot assign to a read-only property $class::\$$name."); } } else { - throw new LogicException("Cannot assign to an undeclared property $class::\$$name"); + throw new MemberAccessException("Cannot assign to an undeclared property $class::\$$name."); } } @@ -207,16 +207,16 @@ abstract class NObject /** - * Access to undeclared property + * Access to undeclared property. * * @param string property name * @return void - * @throws LogicException + * @throws MemberAccessException */ protected function __unset($name) { $class = get_class($this); - throw new LogicException("Cannot unset an property $class::\$$name"); + throw new MemberAccessException("Cannot unset an property $class::\$$name."); } diff --git a/dibi/Nette/exceptions.php b/dibi/Nette/exceptions.php new file mode 100644 index 00000000..ceaedb61 --- /dev/null +++ b/dibi/Nette/exceptions.php @@ -0,0 +1,119 @@ +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 */ diff --git a/dibi/drivers/mysql.php b/dibi/drivers/mysql.php index 4d0c9d67..3b1eb51e 100644 --- a/dibi/drivers/mysql.php +++ b/dibi/drivers/mysql.php @@ -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 */ diff --git a/dibi/drivers/mysqli.php b/dibi/drivers/mysqli.php index 2061f61d..983e7236 100644 --- a/dibi/drivers/mysqli.php +++ b/dibi/drivers/mysqli.php @@ -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 */ diff --git a/dibi/drivers/odbc.php b/dibi/drivers/odbc.php index 77a6d5e2..2799cb3b 100644 --- a/dibi/drivers/odbc.php +++ b/dibi/drivers/odbc.php @@ -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 */ diff --git a/dibi/drivers/oracle.php b/dibi/drivers/oracle.php index c1e70547..cf023b82 100644 --- a/dibi/drivers/oracle.php +++ b/dibi/drivers/oracle.php @@ -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 */ diff --git a/dibi/drivers/pdo.php b/dibi/drivers/pdo.php index 3bfe6462..b12176ef 100644 --- a/dibi/drivers/pdo.php +++ b/dibi/drivers/pdo.php @@ -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 */ diff --git a/dibi/drivers/postgre.php b/dibi/drivers/postgre.php index e40b8f64..22f1316f 100644 --- a/dibi/drivers/postgre.php +++ b/dibi/drivers/postgre.php @@ -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 */ diff --git a/dibi/drivers/sqlite.php b/dibi/drivers/sqlite.php index 440e4074..90fb1442 100644 --- a/dibi/drivers/sqlite.php +++ b/dibi/drivers/sqlite.php @@ -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 */ diff --git a/dibi/libs/DibiConnection.php b/dibi/libs/DibiConnection.php index 38b65ef0..3c614ea0 100644 --- a/dibi/libs/DibiConnection.php +++ b/dibi/libs/DibiConnection.php @@ -20,7 +20,7 @@ /** - * dibi connection + * dibi connection. * * @author David Grudl * @copyright Copyright (c) 2005, 2008 David Grudl @@ -30,13 +30,13 @@ class DibiConnection extends NObject { /** - * Current connection configuration + * Current connection configuration. * @var array */ private $config; /** - * IDibiDriver + * IDibiDriver. * @var array */ private $driver; @@ -56,7 +56,7 @@ class DibiConnection extends NObject /** - * Creates object and (optionally) connects to a database + * Creates object and (optionally) connects to a database. * * @param array|string connection parameters * @throws DibiException @@ -93,7 +93,7 @@ class DibiConnection extends NObject /** - * Automatically frees the resources allocated for this result set + * Automatically frees the resources allocated for this result set. * * @return void */ @@ -106,7 +106,7 @@ class DibiConnection extends NObject /** - * Connects to a database + * Connects to a database. * * @return void */ @@ -122,7 +122,7 @@ class DibiConnection extends NObject /** - * Disconnects from a database + * Disconnects from a database. * * @return void */ @@ -164,7 +164,7 @@ class DibiConnection extends NObject /** - * Apply configuration alias or default values + * Apply configuration alias or default values. * * @param array connect configuration * @param string key @@ -186,7 +186,7 @@ class DibiConnection extends NObject /** - * Returns the connection resource + * Returns the connection resource. * * @return resource */ @@ -198,7 +198,7 @@ class DibiConnection extends NObject /** - * Generates (translates) and executes SQL query + * Generates (translates) and executes SQL query. * * @param array|mixed one or more arguments * @return DibiResult Result set object (if any) @@ -219,7 +219,7 @@ class DibiConnection extends NObject /** - * Generates and prints SQL query + * Generates and prints SQL query. * * @param array|mixed one or more arguments * @return bool @@ -227,6 +227,7 @@ class DibiConnection extends NObject final public function test($args) { $args = func_get_args(); + $this->connect(); $trans = new DibiTranslator($this->driver); $ok = $trans->translate($args); dibi::dump($trans->sql); @@ -236,7 +237,7 @@ class DibiConnection extends NObject /** - * Executes the SQL query + * Executes the SQL query. * * @param string SQL statement. * @return DibiResult Result set object (if any) @@ -265,7 +266,7 @@ class DibiConnection extends NObject /** - * 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 number of rows * @throws DibiException @@ -273,14 +274,14 @@ class DibiConnection extends NObject public function affectedRows() { $rows = $this->driver->affectedRows(); - if (!is_int($rows) || $rows < 0) throw new DibiException('Cannot retrieve number of affected rows'); + if (!is_int($rows) || $rows < 0) throw new DibiException('Cannot retrieve number of affected rows.'); return $rows; } /** - * 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. * * @param string optional sequence name * @return int @@ -289,7 +290,7 @@ class DibiConnection extends NObject public function insertId($sequence = NULL) { $id = $this->driver->insertId($sequence); - if ($id < 1) throw new DibiException('Cannot retrieve last generated ID'); + if ($id < 1) throw new DibiException('Cannot retrieve last generated ID.'); return (int) $id; } @@ -303,7 +304,7 @@ class DibiConnection extends NObject { $this->connect(); if ($this->inTxn) { - throw new DibiException('There is already an active transaction'); + throw new DibiException('There is already an active transaction.'); } $this->driver->begin(); $this->inTxn = TRUE; @@ -319,7 +320,7 @@ class DibiConnection extends NObject public function commit() { if (!$this->inTxn) { - throw new DibiException('There is no active transaction'); + throw new DibiException('There is no active transaction.'); } $this->driver->commit(); $this->inTxn = FALSE; @@ -335,7 +336,7 @@ class DibiConnection extends NObject public function rollback() { if (!$this->inTxn) { - throw new DibiException('There is no active transaction'); + throw new DibiException('There is no active transaction.'); } $this->driver->rollback(); $this->inTxn = FALSE; @@ -345,7 +346,7 @@ class DibiConnection extends NObject /** - * Escapes the string + * Escapes the string. * * @param string unescaped string * @return string escaped and optionally quoted string @@ -359,7 +360,7 @@ class DibiConnection extends NObject /** - * Delimites identifier (table's or column's name, etc.) + * Delimites identifier (table's or column's name, etc.). * * @param string identifier * @return string delimited identifier @@ -372,7 +373,7 @@ class DibiConnection extends NObject /** - * 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 @@ -400,7 +401,7 @@ class DibiConnection extends NObject $handle = @fopen($file, 'r'); if (!$handle) { - throw new DibiException("Cannot open file '$file'"); + throw new FileNotFoundException("Cannot open file '$file'."); } $count = 0; @@ -427,27 +428,27 @@ class DibiConnection extends NObject */ public function getDibiReflection() { - throw new BadMethodCallException(__METHOD__ . ' is not implemented'); + throw new NotImplementedException; } /** - * Prevents unserialization + * Prevents unserialization. */ public function __wakeup() { - throw new DibiException('You cannot serialize or unserialize ' . $this->getClass() . ' instances'); + throw new NotSupportedException('You cannot serialize or unserialize ' . $this->getClass() . ' instances.'); } /** - * Prevents serialization + * Prevents serialization. */ public function __sleep() { - throw new DibiException('You cannot serialize or unserialize ' . $this->getClass() . ' instances'); + throw new NotSupportedException('You cannot serialize or unserialize ' . $this->getClass() . ' instances.'); } } diff --git a/dibi/libs/DibiDataSource.php b/dibi/libs/DibiDataSource.php index cf705431..71467e77 100644 --- a/dibi/libs/DibiDataSource.php +++ b/dibi/libs/DibiDataSource.php @@ -20,7 +20,7 @@ /** - * Default implementation of IDataSource for dibi + * Default implementation of IDataSource for dibi. * * @author David Grudl * @copyright Copyright (c) 2005, 2008 David Grudl diff --git a/dibi/libs/DibiException.php b/dibi/libs/DibiException.php index f50c38fa..ef480b5d 100644 --- a/dibi/libs/DibiException.php +++ b/dibi/libs/DibiException.php @@ -20,7 +20,7 @@ /** - * dibi common exception + * dibi common exception. * * @author David Grudl * @copyright Copyright (c) 2005, 2008 David Grudl @@ -35,7 +35,7 @@ class DibiException extends NException /** - * database server exception + * database server exception. * * @author David Grudl * @copyright Copyright (c) 2005, 2008 David Grudl @@ -49,7 +49,7 @@ class DibiDriverException extends DibiException /** - * Construct an dibi driver exception + * Construct an dibi driver exception. * * @param string Message describing the exception * @param int Some code diff --git a/dibi/libs/DibiLogger.php b/dibi/libs/DibiLogger.php index b73402d7..2f0767c2 100644 --- a/dibi/libs/DibiLogger.php +++ b/dibi/libs/DibiLogger.php @@ -20,7 +20,7 @@ /** - * dibi basic logger & profiler (experimental) + * dibi basic logger & profiler (experimental). * * @author David Grudl * @copyright Copyright (c) 2005, 2008 David Grudl @@ -51,7 +51,7 @@ final class DibiLogger extends NObject /** - * Event handler (events: exception, connected, beforeQuery, afterQuery, begin, commit, rollback) + * Event handler (events: exception, connected, beforeQuery, afterQuery, begin, commit, rollback). * * @param DibiConnection * @param string event name diff --git a/dibi/libs/DibiResult.php b/dibi/libs/DibiResult.php index 7ee4b1c5..693a78c9 100644 --- a/dibi/libs/DibiResult.php +++ b/dibi/libs/DibiResult.php @@ -20,7 +20,7 @@ /** - * dibi result-set abstract class + * dibi result-set abstract class. * * * $result = dibi::query('SELECT * FROM [table]'); @@ -44,25 +44,25 @@ class DibiResult extends NObject implements IDataSource { /** - * IDibiDriver + * IDibiDriver. * @var array */ private $driver; /** - * Translate table + * Translate table. * @var array */ private $xlat; /** - * Cache for $driver->getColumnsMeta() + * Cache for $driver->getColumnsMeta(). * @var array */ private $metaCache; /** - * Already fetched? Used for allowance for first seek(0) + * Already fetched? Used for allowance for first seek(0). * @var bool */ private $fetched = FALSE; @@ -105,7 +105,7 @@ class DibiResult extends NObject implements IDataSource /** - * Automatically frees the resources allocated for this result set + * Automatically frees the resources allocated for this result set. * * @return void */ @@ -117,7 +117,7 @@ class DibiResult extends NObject implements IDataSource /** - * Returns the resultset resource + * Returns the resultset resource. * * @return mixed */ @@ -129,7 +129,7 @@ class DibiResult extends NObject implements IDataSource /** - * 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 @@ -143,7 +143,7 @@ class DibiResult extends NObject implements IDataSource /** - * Returns the number of rows in a result set + * Returns the number of rows in a result set. * * @return int */ @@ -155,7 +155,7 @@ class DibiResult extends NObject implements IDataSource /** - * Frees the resources allocated for this result set + * Frees the resources allocated for this result set. * * @return void */ @@ -216,7 +216,7 @@ class DibiResult extends NObject implements IDataSource /** - * Fetches the row at current position, process optional type conversion + * Fetches the row at current position, process optional type conversion. * and moves the internal cursor to the next position * * @param bool fetch as object? Overrides $this->asObjects @@ -255,7 +255,7 @@ class DibiResult extends NObject implements IDataSource /** - * Like fetch(), but returns only first field + * Like fetch(), but returns only first field. * * @return mixed value on success, FALSE if no next record */ @@ -308,7 +308,7 @@ class DibiResult extends NObject implements IDataSource /** - * Fetches all records from table and returns associative tree + * Fetches all records from table and returns associative tree. * Associative descriptor: assoc1,#,assoc2,=,assoc3,@ * builds a tree: $data[assoc1][index][assoc2]['assoc3']->value = {record} * @@ -328,7 +328,7 @@ class DibiResult extends NObject implements IDataSource // check columns foreach ($assoc as $as) { if ($as !== '#' && $as !== '=' && $as !== '@' && !array_key_exists($as, $row)) { - throw new InvalidArgumentException("Unknown column '$as' in associative descriptor"); + throw new InvalidArgumentException("Unknown column '$as' in associative descriptor."); } } @@ -392,7 +392,7 @@ class DibiResult extends NObject implements IDataSource /** - * Fetches all records from table like $key => $value pairs + * Fetches all records from table like $key => $value pairs. * * @param string associative key * @param string value @@ -409,11 +409,11 @@ class DibiResult extends NObject implements IDataSource if ($value === NULL) { if ($key !== NULL) { - throw new InvalidArgumentException("Either none or both columns must be specified"); + throw new InvalidArgumentException("Either none or both columns must be specified."); } if (count($row) < 2) { - throw new LoginException("Result must have at least two columns"); + throw new UnexpectedValueException("Result must have at least two columns."); } // autodetect @@ -423,7 +423,7 @@ class DibiResult extends NObject implements IDataSource } else { if (!array_key_exists($value, $row)) { - throw new InvalidArgumentException("Unknown value column '$value'"); + throw new InvalidArgumentException("Unknown value column '$value'."); } if ($key === NULL) { // indexed-array @@ -434,7 +434,7 @@ class DibiResult extends NObject implements IDataSource } if (!array_key_exists($key, $row)) { - throw new InvalidArgumentException("Unknown key column '$key'"); + throw new InvalidArgumentException("Unknown key column '$key'."); } } @@ -491,7 +491,7 @@ class DibiResult extends NObject implements IDataSource /** - * Gets an array of meta informations about column + * Gets an array of meta informations about column. * * @return array */ @@ -512,7 +512,7 @@ class DibiResult extends NObject implements IDataSource /** - * Displays complete result-set as HTML table for debug purposes + * Displays complete result-set as HTML table for debug purposes. * * @return void */ @@ -549,7 +549,7 @@ class DibiResult extends NObject implements IDataSource /** - * Required by the IteratorAggregate interface + * Required by the IteratorAggregate interface. * @param int offset * @param int limit * @return ArrayIterator @@ -562,7 +562,7 @@ class DibiResult extends NObject implements IDataSource /** - * Required by the Countable interface + * Required by the Countable interface. * @return int */ final public function count() @@ -573,15 +573,15 @@ class DibiResult extends NObject implements IDataSource /** - * Safe access to property $driver + * Safe access to property $driver. * * @return IDibiDriver - * @throws DibiException + * @throws InvalidStateException */ private function getDriver() { if ($this->driver === NULL) { - throw new DibiException('Resultset was released from memory'); + throw new InvalidStateException('Resultset was released from memory.'); } return $this->driver; diff --git a/dibi/libs/DibiResultIterator.php b/dibi/libs/DibiResultIterator.php index 235298a1..566d5610 100644 --- a/dibi/libs/DibiResultIterator.php +++ b/dibi/libs/DibiResultIterator.php @@ -20,7 +20,7 @@ /** - * External result set iterator + * External result set iterator. * * This can be returned by DibiResult::getIterator() method or using foreach * @@ -62,7 +62,7 @@ final class DibiResultIterator implements Iterator /** - * Required by the Iterator interface + * Required by the Iterator interface. * @param int offset * @param int limit */ @@ -76,7 +76,7 @@ final class DibiResultIterator implements Iterator /** - * Rewinds the Iterator to the first element + * Rewinds the Iterator to the first element. * @return void */ public function rewind() diff --git a/dibi/libs/DibiTable.php b/dibi/libs/DibiTable.php index c48a956d..e45ffd9e 100644 --- a/dibi/libs/DibiTable.php +++ b/dibi/libs/DibiTable.php @@ -54,7 +54,7 @@ abstract class DibiTable extends NObject /** - * Table constructor + * Table constructor. * @param array * @return void */ @@ -72,7 +72,7 @@ abstract class DibiTable extends NObject /** - * Returns the table name + * Returns the table name. * @return string */ public function getName() @@ -83,7 +83,7 @@ abstract class DibiTable extends NObject /** - * Returns the primary key name + * Returns the primary key name. * @return string */ public function getPrimary() @@ -94,7 +94,7 @@ abstract class DibiTable extends NObject /** - * Returns the dibi connection + * Returns the dibi connection. * @return DibiConnection */ public function getConnection() @@ -105,7 +105,7 @@ abstract class DibiTable extends NObject /** - * Setup object + * Setup object. * @return void */ protected function setup() @@ -135,7 +135,7 @@ abstract class DibiTable extends NObject /** - * Inserts row into a table + * Inserts row into a table. * @param array|object * @return int new primary key */ @@ -150,7 +150,7 @@ abstract class DibiTable extends NObject /** - * Updates rows in a table + * Updates rows in a table. * @param mixed primary key value(s) * @param array|object * @return int number of updated rows @@ -168,7 +168,7 @@ abstract class DibiTable extends NObject /** - * Deletes rows from a table by primary key + * Deletes rows from a table by primary key. * @param mixed primary key value(s) * @return int number of deleted rows */ @@ -184,7 +184,7 @@ abstract class DibiTable extends NObject /** - * Finds rows by primary key + * Finds rows by primary key. * @param mixed primary key value(s) * @return DibiResult */ @@ -202,7 +202,7 @@ abstract class DibiTable extends NObject /** - * Selects all rows + * Selects all rows. * @param string column to order by * @return DibiResult */ @@ -224,7 +224,7 @@ abstract class DibiTable extends NObject /** - * Fetches single row + * Fetches single row. * @param scalar primary key value * @return array|object row */ @@ -239,7 +239,7 @@ abstract class DibiTable extends NObject /** - * Returns a blank row (not fetched from database) + * Returns a blank row (not fetched from database). * @return array|object */ public function createBlank() @@ -255,7 +255,7 @@ abstract class DibiTable extends NObject /** - * User data pre-processing + * User data pre-processing. * @param array|object * @return array */ @@ -267,13 +267,13 @@ abstract class DibiTable extends NObject return $data; } - throw new DibiException('Dataset must be array or anonymous object'); + throw new InvalidArgumentException('Dataset must be array or anonymous object.'); } /** - * User DibiResult post-processing + * User DibiResult post-processing. * @param DibiResult * @return DibiResult */ diff --git a/dibi/libs/DibiTranslator.php b/dibi/libs/DibiTranslator.php index 0249a21e..bbddc95b 100644 --- a/dibi/libs/DibiTranslator.php +++ b/dibi/libs/DibiTranslator.php @@ -20,7 +20,7 @@ /** - * dibi SQL translator + * dibi SQL translator. * * @author David Grudl * @copyright Copyright (c) 2005, 2008 David Grudl @@ -69,7 +69,7 @@ final class DibiTranslator extends NObject /** - * return IDibiDriver + * return IDibiDriver. */ public function getDriver() { @@ -79,7 +79,7 @@ final class DibiTranslator extends NObject /** - * Generates SQL + * Generates SQL. * * @param array * @return bool @@ -187,7 +187,7 @@ final class DibiTranslator extends NObject /** - * Apply modifier to single value + * Apply modifier to single value. * @param mixed * @param string * @return string @@ -342,7 +342,7 @@ final class DibiTranslator extends NObject /** - * PREG callback from translate() or formatValue() + * PREG callback from translate() or formatValue(). * @param array * @return string */ @@ -426,7 +426,7 @@ final class DibiTranslator extends NObject if ($matches[2]) // SQL identifiers: [ident] return $this->delimite($matches[2]); - if ($matches[3]) // SQL strings: '....' + if ($matches[3]) // SQL strings: '...' return $this->driver->format( str_replace("''", "'", $matches[4]), dibi::FIELD_TEXT); if ($matches[5]) // SQL strings: "..." @@ -443,7 +443,7 @@ final class DibiTranslator extends NObject /** - * Apply substitutions to indentifier and delimites it + * Apply substitutions to indentifier and delimites it. * * @param string indentifier * @return string diff --git a/dibi/libs/DibiVariable.php b/dibi/libs/DibiVariable.php index 8b918a0d..7ad60d43 100644 --- a/dibi/libs/DibiVariable.php +++ b/dibi/libs/DibiVariable.php @@ -20,7 +20,7 @@ /** - * Default implemenation of IDibiVariable + * Default implemenation of IDibiVariable. * @package dibi */ class DibiVariable extends NObject implements IDibiVariable diff --git a/dibi/libs/interfaces.php b/dibi/libs/interfaces.php index 703f7def..dbc3a139 100644 --- a/dibi/libs/interfaces.php +++ b/dibi/libs/interfaces.php @@ -20,13 +20,13 @@ /** - * Interface for user variable, used for generating SQL + * Interface for user variable, used for generating SQL. * @package dibi */ interface IDibiVariable { /** - * Format for SQL + * Format for SQL. * * @param object DibiTranslator * @param string optional modifier @@ -40,7 +40,7 @@ interface IDibiVariable /** - * Provides an interface between a dataset and data-aware components + * Provides an interface between a dataset and data-aware components. * @package dibi */ interface IDataSource extends Countable, IteratorAggregate @@ -54,7 +54,7 @@ interface IDataSource extends Countable, IteratorAggregate /** - * dibi driver interface + * dibi driver interface. * * @author David Grudl * @copyright Copyright (c) 2005, 2008 David Grudl @@ -65,7 +65,7 @@ interface IDibiDriver { /** - * Internal: Connects to a database + * Internal: Connects to a database. * * @param array * @return void @@ -76,7 +76,7 @@ interface IDibiDriver /** - * Internal: Disconnects from a database + * Internal: Disconnects from a database. * * @return void * @throws DibiException @@ -86,7 +86,7 @@ interface IDibiDriver /** - * Internal: Executes the SQL query + * Internal: Executes the SQL query. * * @param string SQL statement. * @return bool have resultset? @@ -97,7 +97,7 @@ interface 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 */ @@ -106,7 +106,7 @@ interface 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 */ @@ -142,7 +142,7 @@ interface 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) @@ -152,7 +152,7 @@ interface IDibiDriver /** - * 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 @@ -164,7 +164,7 @@ interface IDibiDriver /** - * Returns the number of rows in a result set + * Returns the number of rows in a result set. * * @return int */ @@ -173,7 +173,7 @@ interface 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 @@ -184,7 +184,7 @@ interface 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 @@ -195,7 +195,7 @@ interface IDibiDriver /** - * Frees the resources allocated for this result set + * Frees the resources allocated for this result set. * * @param resource resultset resource * @return void @@ -205,7 +205,7 @@ interface IDibiDriver /** - * Returns metadata for all columns in a result set + * Returns metadata for all columns in a result set. * * @return array * @throws DibiException @@ -215,7 +215,7 @@ interface IDibiDriver /** - * Returns the connection resource + * Returns the connection resource. * * @return mixed */ @@ -224,7 +224,7 @@ interface IDibiDriver /** - * Returns the resultset resource + * Returns the resultset resource. * * @return mixed */