1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-04 21:28:02 +02:00

- query returns DibiResult or number of affected rows now

This commit is contained in:
David Grudl
2009-02-05 02:13:15 +00:00
parent bf6dc1cbd1
commit 32ed383326
3 changed files with 11 additions and 7 deletions

View File

@@ -264,7 +264,7 @@ class dibi
/**
* Generates and executes SQL query - Monostate for DibiConnection::query().
* @param array|mixed one or more arguments
* @return DibiResult|NULL result set object (if any)
* @return DibiResult|int result set object (if any)
* @throws DibiException
*/
public static function query($args)
@@ -278,7 +278,7 @@ class dibi
/**
* Executes the SQL query - Monostate for DibiConnection::nativeQuery().
* @param string SQL statement.
* @return DibiResult|NULL result set object (if any)
* @return DibiResult|int result set object (if any)
*/
public static function nativeQuery($sql)
{

View File

@@ -235,7 +235,7 @@ class DibiConnection extends DibiObject
/**
* Generates (translates) and executes SQL query.
* @param array|mixed one or more arguments
* @return DibiResult|NULL result set object (if any)
* @return DibiResult|int result set object (if any)
* @throws DibiException
*/
final public function query($args)
@@ -292,7 +292,7 @@ class DibiConnection extends DibiObject
/**
* Executes the SQL query.
* @param string SQL statement.
* @return DibiResult|NULL result set object (if any)
* @return DibiResult|int result set object (if any)
* @throws DibiException
*/
final public function nativeQuery($sql)
@@ -318,6 +318,8 @@ class DibiConnection extends DibiObject
if ($res = $this->driver->query($sql)) { // intentionally =
$res = new DibiResult($res, $this->config);
} else {
$res = $this->driver->affectedRows();
}
$time += microtime(TRUE);

View File

@@ -240,12 +240,14 @@ class DibiFluent extends DibiObject implements Countable, IteratorAggregate
/**
* Generates and executes SQL query.
* @return DibiResult|NULL result set object (if any)
* @param mixed what to return?
* @return DibiResult|int result set object (if any)
* @throws DibiException
*/
public function execute()
public function execute($return = NULL)
{
return $this->connection->query($this->_export());
$res = $this->connection->query($this->_export());
return $return === dibi::IDENTIFIER ? $this->connection->insertId() : $res;
}