diff --git a/dibi/dibi.php b/dibi/dibi.php index f7593d3a..2477374b 100644 --- a/dibi/dibi.php +++ b/dibi/dibi.php @@ -14,7 +14,7 @@ * @author David Grudl * @copyright Copyright (c) 2005, 2007 David Grudl * @license http://php7.org/dibi/license (dibi license) - * @version 0.9a (Revision: $WCREV$, Date: $WCDATE$) + * @version 0.9b (Revision: $WCREV$, Date: $WCDATE$) * @category Database * @package Dibi * @link http://php7.org/dibi/ @@ -24,13 +24,10 @@ /** * Check PHP configuration */ -if (version_compare(PHP_VERSION , '5.0.3', '<')) { - throw new Exception('dibi needs PHP 5.0.3 or newer'); +if (version_compare(PHP_VERSION , '5.1.0', '<')) { + throw new Exception('dibi needs PHP 5.1.0 or newer'); } -if (preg_match('#on$|true$|yes$|[+-]?0*[1-9]#iA', ini_get('zend.ze1_compatibility_mode'))) { - throw new Exception('dibi cannot run with zend.ze1_compatibility_mode enabled'); -} @@ -91,7 +88,7 @@ class dibi FIELD_COUNTER = 'c', // counter or autoincrement, is integer // dibi version - VERSION = '0.9a (Revision: $WCREV$, Date: $WCDATE$)'; + VERSION = '0.9b (Revision: $WCREV$, Date: $WCDATE$)'; /** @@ -400,11 +397,12 @@ class dibi * * @param callback * @return void + * @throws InvalidArgumentException */ public static function addHandler($callback) { if (!is_callable($callback)) { - throw new DibiException("Invalid callback"); + throw new InvalidArgumentException("Invalid callback"); } self::$handlers[] = $callback; diff --git a/dibi/drivers/untested/mssql.php b/dibi/drivers/mssql.php similarity index 92% rename from dibi/drivers/untested/mssql.php rename to dibi/drivers/mssql.php index 068d8bea..1fc1cd1d 100644 --- a/dibi/drivers/untested/mssql.php +++ b/dibi/drivers/mssql.php @@ -99,7 +99,7 @@ class DibiMsSqlDriver extends DibiDriver public function insertId() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } @@ -157,7 +157,7 @@ class DibiMsSqlDriver extends DibiDriver public function getMetaData() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } @@ -173,7 +173,7 @@ class DibiMsSqlDriver extends DibiDriver } if ($offset) { - throw new DibiException('Offset is not implemented'); + throw new InvalidArgumentException('Offset is not implemented'); } } diff --git a/dibi/drivers/mysql.php b/dibi/drivers/mysql.php index bbe20d60..a1ae88be 100644 --- a/dibi/drivers/mysql.php +++ b/dibi/drivers/mysql.php @@ -115,8 +115,8 @@ class DibiMySqlDriver extends DibiDriver $connection = $this->getConnection(); $res = @mysql_query($sql, $connection); - if ($res === FALSE) { - throw new DibiDatabaseException(mysql_error($connection), mysql_errno($connection), $sql); + if ($errno = mysql_errno($connection)) { + throw new DibiDatabaseException(mysql_error($connection), $errno, $sql); } return is_resource($res) ? new DibiMySqlResult($res) : TRUE; @@ -194,7 +194,7 @@ class DibiMySqlDriver extends DibiDriver public function getMetaData() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } diff --git a/dibi/drivers/mysqli.php b/dibi/drivers/mysqli.php index 3fd66e03..67446593 100644 --- a/dibi/drivers/mysqli.php +++ b/dibi/drivers/mysqli.php @@ -89,8 +89,8 @@ class DibiMySqliDriver extends DibiDriver $connection = $this->getConnection(); $res = @mysqli_query($connection, $sql); - if ($res === FALSE) { - throw new DibiDatabaseException(mysqli_error($connection), mysqli_errno($connection), $sql); + if ($errno = mysqli_errno($connection)) { + throw new DibiDatabaseException(mysqli_error($connection), $errno, $sql); } return is_object($res) ? new DibiMySqliResult($res) : TRUE; @@ -179,7 +179,7 @@ class DibiMySqliDriver extends DibiDriver public function getMetaData() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } diff --git a/dibi/drivers/odbc.php b/dibi/drivers/odbc.php index d10e0457..1cd4be84 100644 --- a/dibi/drivers/odbc.php +++ b/dibi/drivers/odbc.php @@ -122,7 +122,7 @@ class DibiOdbcDriver extends DibiDriver public function insertId() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } @@ -192,7 +192,7 @@ class DibiOdbcDriver extends DibiDriver public function getMetaData() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } @@ -207,7 +207,7 @@ class DibiOdbcDriver extends DibiDriver $sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')'; } - if ($offset) throw new DibiException('Offset is not implemented in driver odbc'); + if ($offset) throw new InvalidArgumentException('Offset is not implemented in driver odbc'); } diff --git a/dibi/drivers/untested/oracle.php b/dibi/drivers/oracle.php similarity index 88% rename from dibi/drivers/untested/oracle.php rename to dibi/drivers/oracle.php index b0cbca49..127fdfd4 100644 --- a/dibi/drivers/untested/oracle.php +++ b/dibi/drivers/oracle.php @@ -80,8 +80,8 @@ class DibiOracleDriver extends DibiDriver $statement = oci_parse($connection, $sql); if ($statement) { $res = oci_execute($statement, $this->autocommit ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT); - if (!$res) { - $err = oci_error($statement); + $err = oci_error($statement); + if ($err) { throw new DibiDatabaseException($err['message'], $err['code'], $sql); } } else { @@ -97,14 +97,14 @@ class DibiOracleDriver extends DibiDriver public function affectedRows() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } public function insertId() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } @@ -167,7 +167,7 @@ class DibiOracleDriver extends DibiDriver public function getMetaData() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } @@ -210,7 +210,7 @@ class DibiOracleResult extends DibiResult public function seek($row) { - //throw new DibiException(__METHOD__ . ' is not implemented'); + //throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } diff --git a/dibi/drivers/untested/pdo.php b/dibi/drivers/pdo.php similarity index 88% rename from dibi/drivers/untested/pdo.php rename to dibi/drivers/pdo.php index df583626..2a1b9f33 100644 --- a/dibi/drivers/untested/pdo.php +++ b/dibi/drivers/pdo.php @@ -76,7 +76,7 @@ class DibiPdoDriver extends DibiDriver public function affectedRows() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } @@ -127,7 +127,7 @@ class DibiPdoDriver extends DibiDriver public function escape($value, $appendQuotes = TRUE) { if (!$appendQuotes) { - throw new DibiException('Escaping without qoutes is not supported by PDO'); + throw new BadMethodCallException('Escaping without qoutes is not supported by PDO'); } return $this->getConnection()->quote($value); } @@ -144,7 +144,7 @@ class DibiPdoDriver extends DibiDriver public function getMetaData() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } @@ -154,7 +154,7 @@ class DibiPdoDriver extends DibiDriver */ public function applyLimit(&$sql, $limit, $offset = 0) { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } } // class DibiPdoDriver diff --git a/dibi/drivers/postgre.php b/dibi/drivers/postgre.php index b11d0721..b6463111 100644 --- a/dibi/drivers/postgre.php +++ b/dibi/drivers/postgre.php @@ -191,7 +191,7 @@ class DibiPostgreDriver extends DibiDriver public function getMetaData() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } diff --git a/dibi/drivers/sqlite.php b/dibi/drivers/sqlite.php index 144dfc4e..37646b22 100644 --- a/dibi/drivers/sqlite.php +++ b/dibi/drivers/sqlite.php @@ -79,9 +79,8 @@ class DibiSqliteDriver extends DibiDriver $connection = $this->getConnection(); $res = @sqlite_query($connection, $sql, SQLITE_ASSOC); - if ($res === FALSE) { - $code = sqlite_last_error($connection); - throw new DibiDatabaseException(sqlite_error_string($code), $code, $sql); + if ($errno = sqlite_last_error($connection)) { + throw new DibiDatabaseException(sqlite_error_string($errno), $errno, $sql); } return is_resource($res) ? new DibiSqliteResult($res) : TRUE; @@ -158,7 +157,7 @@ class DibiSqliteDriver extends DibiDriver public function getMetaData() { - throw new DibiException(__METHOD__ . ' is not implemented'); + throw new BadMethodCallException(__METHOD__ . ' is not implemented'); } diff --git a/dibi/libs/resultset.php b/dibi/libs/resultset.php index aa23e2ae..312644d3 100644 --- a/dibi/libs/resultset.php +++ b/dibi/libs/resultset.php @@ -21,16 +21,6 @@ -// PHP < 5.1 compatibility -if (!interface_exists('Countable', FALSE)) { - interface Countable - { - function count(); - } -} - - - /** * dibi result-set abstract class * diff --git a/readme.txt b/readme.txt index f723df10..8dc1bb63 100644 --- a/readme.txt +++ b/readme.txt @@ -10,7 +10,7 @@ Thank you for downloading Dibi! Database access functions in PHP are not standardised. This is class library to hide the differences between the different databases access. -The files in this archive are released under the NEW BSD license. +The files in this archive are released under the Dibi license. See license.txt in this directory for a copy of the license. diff --git a/version.txt b/version.txt index 86c8749f..7b8fa205 100644 --- a/version.txt +++ b/version.txt @@ -1,4 +1,4 @@ -Dibi version 0.9a +Dibi version 0.9b Revision: $WCREV$ Date: $WCDATE$