1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-04 21:28:02 +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

@@ -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)
{

View File

@@ -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.");
}

119
dibi/Nette/exceptions.php Normal file
View File

@@ -0,0 +1,119 @@
<?php
/**
* Nette Framework
*
* Copyright (c) 2004, 2008 David Grudl aka -dgx- (http://www.dgx.cz)
*
* This source file is subject to the "Nette license" that is bundled
* with this package in the file license.txt.
*
* For more information please see http://nettephp.com/
*
* @copyright Copyright (c) 2004, 2008 David Grudl
* @license http://nettephp.com/license Nette license
* @link http://nettephp.com/
* @category Nette
* @package Nette
*/
// no namespace;
/*
some useful SPL exception:
- LogicException
- InvalidArgumentException
- LengthException
- RuntimeException
- OutOfBoundsException
- UnexpectedValueException
other SPL exceptions are ambiguous; do not use them
*/
/**
* The exception that is thrown when the value of an argument is
* outside the allowable range of values as defined by the invoked method.
*/
class ArgumentOutOfRangeException extends InvalidArgumentException
{
}
/**
* The exception that is thrown when a method call is invalid for the object's
* current state, method has been invoked at an illegal or inappropriate time.
*/
class InvalidStateException extends RuntimeException // or InvalidOperationException?
{
}
/**
* The exception that is thrown when a requested method or operation is not implemented.
*/
class NotImplementedException extends LogicException
{
}
/**
* The exception that is thrown when an invoked method is not supported. For scenarios where
* it is sometimes possible to perform the requested operation, see InvalidStateException.
*/
class NotSupportedException extends LogicException
{
}
/**
* The exception that is thrown when accessing a class member (property or method) fails.
*/
class MemberAccessException extends LogicException
{
}
/**
* The exception that is thrown when an I/O error occurs.
*/
class IOException extends RuntimeException
{
}
/**
* The exception that is thrown when accessing a file that does not exist on disk.
*/
class FileNotFoundException extends IOException
{
}
/**
* The exception that is thrown when part of a file or directory cannot be found.
*/
class DirectoryNotFoundException extends IOException
{
}
/**
* User attempt to terminate the current script
*/
class AbortException extends RuntimeException
{
}

View File

@@ -21,18 +21,19 @@
/**
* Check PHP configuration
* Check PHP configuration.
*/
if (version_compare(PHP_VERSION , '5.1.0', '<')) {
throw new Exception('dibi needs PHP 5.1.0 or newer');
throw new LogicException('dibi needs PHP 5.1.0 or newer.');
}
// nette libraries
if (!class_exists('NObject', FALSE)) { require_once dirname(__FILE__) . '/libs/NObject.php'; }
if (!class_exists('NException', FALSE)) { require_once dirname(__FILE__) . '/libs/NException.php'; }
if (!class_exists('NotImplementedException', FALSE)) { require_once dirname(__FILE__) . '/Nette/exceptions.php'; }
if (!class_exists('NObject', FALSE)) { require_once dirname(__FILE__) . '/Nette/NObject.php'; }
if (!class_exists('NException', FALSE)) { require_once dirname(__FILE__) . '/Nette/NException.php'; }
// dibi libraries
require_once dirname(__FILE__) . '/libs/interfaces.php';
@@ -51,7 +52,7 @@ require_once dirname(__FILE__) . '/libs/DibiDataSource.php';
/**
* Interface for database drivers
* Interface for database drivers.
*
* This class is static container class for creating DB objects and
* store connections info.
@@ -64,7 +65,7 @@ require_once dirname(__FILE__) . '/libs/DibiDataSource.php';
class dibi
{
/**
* Column type in relation to PHP native type
* Column type in relation to PHP native type.
*/
const
FIELD_TEXT = 's', // as 'string'
@@ -85,19 +86,19 @@ class dibi
/**
* Connection registry storage for DibiConnection objects
* Connection registry storage for DibiConnection objects.
* @var DibiConnection[]
*/
private static $registry = array();
/**
* Current connection
* Current connection.
* @var DibiConnection
*/
private static $connection;
/**
* Substitutions for identifiers
* Substitutions for identifiers.
* @var array
*/
private static $substs = array();
@@ -115,25 +116,25 @@ class dibi
public static $sql;
/**
* Elapsed time for last query
* Elapsed time for last query.
* @var int
*/
public static $elapsedTime;
/**
* Elapsed time for all queries
* Elapsed time for all queries.
* @var int
*/
public static $totalTime;
/**
* Number or queries
* Number or queries.
* @var int
*/
public static $numOfQueries = 0;
/**
* Default dibi driver
* Default dibi driver.
* @var string
*/
public static $defaultDriver = 'mysql';
@@ -144,7 +145,7 @@ class dibi
/**
* Static class - cannot be instantiated
* Static class - cannot be instantiated.
*/
final public function __construct()
{
@@ -154,7 +155,7 @@ class dibi
/**
* Creates a new DibiConnection object and connects it to specified database
* Creates a new DibiConnection object and connects it to specified database.
*
* @param array|string connection parameters
* @param string connection name
@@ -174,7 +175,7 @@ class dibi
/**
* Disconnects from database (doesn't destroy DibiConnection object)
* Disconnects from database (doesn't destroy DibiConnection object).
*
* @return void
*/
@@ -186,7 +187,7 @@ class dibi
/**
* Returns TRUE when connection was established
* Returns TRUE when connection was established.
*
* @return bool
*/
@@ -198,7 +199,7 @@ class dibi
/**
* Retrieve active connection
* Retrieve active connection.
*
* @param string connection registy name
* @return object DibiConnection object.
@@ -208,7 +209,7 @@ class dibi
{
if ($name === NULL) {
if (!self::$connection) {
throw new DibiException('Dibi is not connected to database');
throw new DibiException('Dibi is not connected to database.');
}
return self::$connection;
@@ -224,7 +225,7 @@ class dibi
/**
* Change active connection
* Change active connection.
*
* @param string connection registy name
* @return void
@@ -238,7 +239,7 @@ class dibi
/**
* Generates and executes SQL query - Monostate for DibiConnection::query()
* Generates and executes SQL query - Monostate for DibiConnection::query().
*
* @param array|mixed one or more arguments
* @return DibiResult Result set object (if any)
@@ -253,7 +254,7 @@ class dibi
/**
* Executes the SQL query - Monostate for DibiConnection::nativeQuery()
* Executes the SQL query - Monostate for DibiConnection::nativeQuery().
*
* @param string SQL statement.
* @return DibiResult Result set object (if any)
@@ -266,7 +267,7 @@ class dibi
/**
* Generates and prints SQL query - Monostate for DibiConnection::test()
* Generates and prints SQL query - Monostate for DibiConnection::test().
*
* @param array|mixed one or more arguments
* @return bool
@@ -280,7 +281,7 @@ class dibi
/**
* Executes SQL query and fetch result - Monostate for DibiConnection::query() & fetch()
* Executes SQL query and fetch result - Monostate for DibiConnection::query() & fetch().
*
* @param array|mixed one or more arguments
* @return array
@@ -295,7 +296,7 @@ class dibi
/**
* Executes SQL query and fetch results - Monostate for DibiConnection::query() & fetchAll()
* Executes SQL query and fetch results - Monostate for DibiConnection::query() & fetchAll().
*
* @param array|mixed one or more arguments
* @return array
@@ -310,7 +311,7 @@ class dibi
/**
* Executes SQL query and fetch first column - Monostate for DibiConnection::query() & fetchSingle()
* Executes SQL query and fetch first column - Monostate for DibiConnection::query() & fetchSingle().
*
* @param array|mixed one or more arguments
* @return string
@@ -325,7 +326,7 @@ class dibi
/**
* Gets the number of affected rows
* Gets the number of affected rows.
* Monostate for DibiConnection::affectedRows()
*
* @return int number of rows
@@ -339,7 +340,7 @@ class dibi
/**
* 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.
* Monostate for DibiConnection::insertId()
*
* @param string optional sequence name
@@ -354,7 +355,7 @@ class dibi
/**
* Begins a transaction - Monostate for DibiConnection::begin()
* Begins a transaction - Monostate for DibiConnection::begin().
* @return void
* @throws DibiException
*/
@@ -366,7 +367,7 @@ class dibi
/**
* Commits statements in a transaction - Monostate for DibiConnection::commit()
* Commits statements in a transaction - Monostate for DibiConnection::commit().
* @return void
* @throws DibiException
*/
@@ -378,7 +379,7 @@ class dibi
/**
* Rollback changes in a transaction - Monostate for DibiConnection::rollback()
* Rollback changes in a transaction - Monostate for DibiConnection::rollback().
* @return void
* @throws DibiException
*/
@@ -403,7 +404,7 @@ class dibi
/**
* Experimental; will be used in PHP 5.3
* Experimental; will be used in PHP 5.3.
*/
public static function __callStatic($name, $args)
{
@@ -413,7 +414,7 @@ class dibi
/**
* Pseudotype for timestamp representation
* Pseudotype for timestamp representation.
*
* @param mixed datetime
* @return DibiVariable
@@ -433,7 +434,7 @@ class dibi
/**
* Pseudotype for date representation
* Pseudotype for date representation.
*
* @param mixed date
* @return DibiVariable
@@ -448,7 +449,7 @@ class dibi
/**
* Create a new substitution pair for indentifiers
* Create a new substitution pair for indentifiers.
*
* @param string from
* @param string to
@@ -462,7 +463,7 @@ class dibi
/**
* Remove substitution pair
* Remove substitution pair.
*
* @param mixed from or TRUE
* @return void
@@ -479,7 +480,7 @@ class dibi
/**
* Returns substitution pairs
* Returns substitution pairs.
*
* @return array
*/
@@ -491,7 +492,7 @@ class dibi
/**
* Add new event handler
* Add new event handler.
*
* @param callback
* @return void
@@ -500,7 +501,7 @@ class dibi
public static function addHandler($callback)
{
if (!is_callable($callback)) {
throw new InvalidArgumentException("Invalid callback");
throw new InvalidArgumentException("Invalid callback.");
}
self::$handlers[] = $callback;
@@ -509,7 +510,7 @@ class dibi
/**
* Event notification (events: exception, connected, beforeQuery, afterQuery, begin, commit, rollback)
* Event notification (events: exception, connected, beforeQuery, afterQuery, begin, commit, rollback).
*
* @param DibiConnection
* @param string event name
@@ -526,7 +527,7 @@ class dibi
/**
* Enable profiler & logger
* Enable profiler & logger.
*
* @param string filename
* @param bool log all queries?
@@ -543,7 +544,7 @@ class dibi
/**
* Prints out a syntax highlighted version of the SQL command or DibiResult
* Prints out a syntax highlighted version of the SQL command or DibiResult.
*
* @param string|DibiResult
* @param bool return output instead of printing it?

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
*/

View File

@@ -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.');
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -20,7 +20,7 @@
/**
* dibi result-set abstract class
* dibi result-set abstract class.
*
* <code>
* $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;

View File

@@ -20,7 +20,7 @@
/**
* External result set iterator
* External result set iterator.
*
* This can be returned by DibiResult::getIterator() method or using foreach
* <code>
@@ -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()

View File

@@ -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
*/

View File

@@ -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

View File

@@ -20,7 +20,7 @@
/**
* Default implemenation of IDibiVariable
* Default implemenation of IDibiVariable.
* @package dibi
*/
class DibiVariable extends NObject implements IDibiVariable

View File

@@ -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
*/