1
0
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:
David Grudl
2007-11-08 03:32:37 +00:00
parent 453cc9be13
commit 25fa4293fc
12 changed files with 34 additions and 47 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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