mirror of
https://github.com/dg/dibi.git
synced 2025-08-04 21:28:02 +02:00
DibiDriver::doQuery returns TRUE or DibiResult
This commit is contained in:
@@ -247,7 +247,7 @@ class dibi
|
||||
* Generates and executes SQL query - Monostate for DibiDriver::query()
|
||||
*
|
||||
* @param array|mixed one or more arguments
|
||||
* @return int|DibiResult
|
||||
* @return DibiResult|TRUE
|
||||
* @throws DibiException
|
||||
*/
|
||||
public static function query($args)
|
||||
@@ -263,7 +263,7 @@ class dibi
|
||||
* Executes the SQL query - Monostate for DibiDriver::nativeQuery()
|
||||
*
|
||||
* @param string SQL statement.
|
||||
* @return object|bool Result set object or TRUE on success, FALSE on failure
|
||||
* @return DibiResult|TRUE
|
||||
*/
|
||||
public static function nativeQuery($sql)
|
||||
{
|
||||
|
@@ -74,10 +74,9 @@ class DibiMsSqlDriver extends DibiDriver
|
||||
|
||||
if ($res === FALSE) {
|
||||
throw new DibiDatabaseException('Query error', 0, $sql);
|
||||
|
||||
} elseif (is_resource($res)) {
|
||||
return new DibiMSSqlResult($res);
|
||||
}
|
||||
|
||||
return is_resource($res) ? new DibiMSSqlResult($res) : TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -105,10 +105,9 @@ class DibiMySqlDriver extends DibiDriver
|
||||
|
||||
if ($res === FALSE) {
|
||||
throw new DibiDatabaseException(mysql_error($connection), mysql_errno($connection), $sql);
|
||||
|
||||
} elseif (is_resource($res)) {
|
||||
return new DibiMySqlResult($res);
|
||||
}
|
||||
|
||||
return is_resource($res) ? new DibiMySqlResult($res) : TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -79,10 +79,9 @@ class DibiMySqliDriver extends DibiDriver
|
||||
|
||||
if ($res === FALSE) {
|
||||
throw new DibiDatabaseException(mysqli_error($connection), mysqli_errno($connection), $sql);
|
||||
|
||||
} elseif (is_object($res)) {
|
||||
return new DibiMySqliResult($res);
|
||||
}
|
||||
|
||||
return is_object($res) ? new DibiMySqliResult($res) : TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -105,10 +105,9 @@ class DibiOdbcDriver extends DibiDriver
|
||||
|
||||
if ($res === FALSE) {
|
||||
throw new DibiDatabaseException(odbc_errormsg($connection), odbc_error($connection), $sql);
|
||||
|
||||
} elseif (is_resource($res)) {
|
||||
return new DibiOdbcResult($res);
|
||||
}
|
||||
|
||||
return is_resource($res) ? new DibiOdbcResult($res) : TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -64,16 +64,14 @@ class DibiPdoDriver extends DibiDriver
|
||||
protected function doQuery($sql)
|
||||
{
|
||||
$res = $this->getConnection()->query($sql);
|
||||
if ($res instanceof PDOStatement) {
|
||||
return new DibiPdoResult($res);
|
||||
}
|
||||
return $res instanceof PDOStatement ? new DibiPdoResult($res) : TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function affectedRows()
|
||||
{
|
||||
// not implemented
|
||||
throw new DibiException(__METHOD__ . ' is not implemented');
|
||||
}
|
||||
|
||||
|
||||
|
@@ -99,10 +99,9 @@ class DibiPostgreDriver extends DibiDriver
|
||||
|
||||
if ($res === FALSE) {
|
||||
throw new DibiDatabaseException(pg_last_error($connection), 0, $sql);
|
||||
|
||||
} elseif (is_resource($res)) {
|
||||
return new DibiPostgreResult($res);
|
||||
}
|
||||
|
||||
return is_resource($res) ? new DibiPostgreResult($res) : TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -77,10 +77,9 @@ class DibiSqliteDriver extends DibiDriver
|
||||
if ($res === FALSE) {
|
||||
$code = sqlite_last_error($connection);
|
||||
throw new DibiDatabaseException(sqlite_error_string($code), $code, $sql);
|
||||
|
||||
} elseif (is_resource($res)) {
|
||||
return new DibiSqliteResult($res);
|
||||
}
|
||||
|
||||
return is_resource($res) ? new DibiSqliteResult($res) : TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -114,7 +114,7 @@ abstract class DibiDriver
|
||||
* Generates (translates) and executes SQL query
|
||||
*
|
||||
* @param array|mixed one or more arguments
|
||||
* @return int|DibiResult
|
||||
* @return DibiResult|TRUE
|
||||
* @throws DibiException
|
||||
*/
|
||||
final public function query($args)
|
||||
@@ -153,7 +153,7 @@ abstract class DibiDriver
|
||||
* Executes the SQL query
|
||||
*
|
||||
* @param string SQL statement.
|
||||
* @return DibiResult|NULL Result set object
|
||||
* @return DibiResult|TRUE Result set object
|
||||
* @throws DibiException
|
||||
*/
|
||||
public function nativeQuery($sql)
|
||||
@@ -170,7 +170,7 @@ abstract class DibiDriver
|
||||
* Internal: Executes the SQL query
|
||||
*
|
||||
* @param string SQL statement.
|
||||
* @return DibiResult|NULL Result set object
|
||||
* @return DibiResult|TRUE Result set object
|
||||
* @throws DibiDatabaseException
|
||||
*/
|
||||
abstract protected function doQuery($sql);
|
||||
|
@@ -76,6 +76,7 @@ final class DibiLogger
|
||||
. ";\n-- " . date('Y-m-d H:i:s')
|
||||
. "\n\n"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user