1
0
mirror of https://github.com/dg/dibi.git synced 2025-10-20 01:06:25 +02:00

added new Nette exceptions

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

View File

@@ -19,7 +19,7 @@
/**
* The dibi driver for 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
*/