mirror of
https://github.com/dg/dibi.git
synced 2025-08-20 12:51:40 +02:00
* new exceptions: BadMethodCallException, InvalidArgumentException
* DibiMySqlDriver, DibiMySqliDriver, DibiSqliteDriver, DibiOracleDriver: error checking instead of FALSE checking in doQuery
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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');
|
||||
}
|
||||
|
||||
|
@@ -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
|
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user