1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-05 05:37:39 +02:00

DibiDriver::doQuery returns TRUE or DibiResult

This commit is contained in:
David Grudl
2007-10-01 05:34:50 +00:00
parent d35a850311
commit ccea418c34
10 changed files with 20 additions and 27 deletions

View File

@@ -247,7 +247,7 @@ class dibi
* Generates and executes SQL query - Monostate for DibiDriver::query() * Generates and executes SQL query - Monostate for DibiDriver::query()
* *
* @param array|mixed one or more arguments * @param array|mixed one or more arguments
* @return int|DibiResult * @return DibiResult|TRUE
* @throws DibiException * @throws DibiException
*/ */
public static function query($args) public static function query($args)
@@ -263,7 +263,7 @@ class dibi
* Executes the SQL query - Monostate for DibiDriver::nativeQuery() * Executes the SQL query - Monostate for DibiDriver::nativeQuery()
* *
* @param string SQL statement. * @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) public static function nativeQuery($sql)
{ {

View File

@@ -74,10 +74,9 @@ class DibiMsSqlDriver extends DibiDriver
if ($res === FALSE) { if ($res === FALSE) {
throw new DibiDatabaseException('Query error', 0, $sql); throw new DibiDatabaseException('Query error', 0, $sql);
} elseif (is_resource($res)) {
return new DibiMSSqlResult($res);
} }
return is_resource($res) ? new DibiMSSqlResult($res) : TRUE;
} }

View File

@@ -105,10 +105,9 @@ class DibiMySqlDriver extends DibiDriver
if ($res === FALSE) { if ($res === FALSE) {
throw new DibiDatabaseException(mysql_error($connection), mysql_errno($connection), $sql); 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;
} }

View File

@@ -79,10 +79,9 @@ class DibiMySqliDriver extends DibiDriver
if ($res === FALSE) { if ($res === FALSE) {
throw new DibiDatabaseException(mysqli_error($connection), mysqli_errno($connection), $sql); 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;
} }

View File

@@ -105,10 +105,9 @@ class DibiOdbcDriver extends DibiDriver
if ($res === FALSE) { if ($res === FALSE) {
throw new DibiDatabaseException(odbc_errormsg($connection), odbc_error($connection), $sql); 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;
} }

View File

@@ -64,16 +64,14 @@ class DibiPdoDriver extends DibiDriver
protected function doQuery($sql) protected function doQuery($sql)
{ {
$res = $this->getConnection()->query($sql); $res = $this->getConnection()->query($sql);
if ($res instanceof PDOStatement) { return $res instanceof PDOStatement ? new DibiPdoResult($res) : TRUE;
return new DibiPdoResult($res);
}
} }
public function affectedRows() public function affectedRows()
{ {
// not implemented throw new DibiException(__METHOD__ . ' is not implemented');
} }

View File

@@ -99,10 +99,9 @@ class DibiPostgreDriver extends DibiDriver
if ($res === FALSE) { if ($res === FALSE) {
throw new DibiDatabaseException(pg_last_error($connection), 0, $sql); 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;
} }

View File

@@ -77,10 +77,9 @@ class DibiSqliteDriver extends DibiDriver
if ($res === FALSE) { if ($res === FALSE) {
$code = sqlite_last_error($connection); $code = sqlite_last_error($connection);
throw new DibiDatabaseException(sqlite_error_string($code), $code, $sql); 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;
} }

View File

@@ -114,7 +114,7 @@ abstract class DibiDriver
* Generates (translates) and executes SQL query * Generates (translates) and executes SQL query
* *
* @param array|mixed one or more arguments * @param array|mixed one or more arguments
* @return int|DibiResult * @return DibiResult|TRUE
* @throws DibiException * @throws DibiException
*/ */
final public function query($args) final public function query($args)
@@ -153,7 +153,7 @@ abstract class DibiDriver
* Executes the SQL query * Executes the SQL query
* *
* @param string SQL statement. * @param string SQL statement.
* @return DibiResult|NULL Result set object * @return DibiResult|TRUE Result set object
* @throws DibiException * @throws DibiException
*/ */
public function nativeQuery($sql) public function nativeQuery($sql)
@@ -170,7 +170,7 @@ abstract class DibiDriver
* Internal: Executes the SQL query * Internal: Executes the SQL query
* *
* @param string SQL statement. * @param string SQL statement.
* @return DibiResult|NULL Result set object * @return DibiResult|TRUE Result set object
* @throws DibiDatabaseException * @throws DibiDatabaseException
*/ */
abstract protected function doQuery($sql); abstract protected function doQuery($sql);

View File

@@ -76,6 +76,7 @@ final class DibiLogger
. ";\n-- " . date('Y-m-d H:i:s') . ";\n-- " . date('Y-m-d H:i:s')
. "\n\n" . "\n\n"
); );
return;
} }
} }