1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-30 09:19:48 +02:00

Compare commits

...

1 Commits

Author SHA1 Message Date
David Grudl
7a775aad4f fetchSingle returns FALSE 2018-05-17 13:27:45 +02:00
4 changed files with 7 additions and 4 deletions

View File

@@ -161,7 +161,7 @@ class DataSource implements IDataSource
/**
* Like fetch(), but returns only first field.
* @return mixed value on success, null if no next record
* @return mixed value on success, false if no next record
*/
public function fetchSingle()
{

View File

@@ -311,7 +311,7 @@ class Fluent implements IDataSource
/**
* Like fetch(), but returns only first field.
* @return mixed value on success, null if no next record
* @return mixed value on success, false if no next record
*/
public function fetchSingle()
{

View File

@@ -179,13 +179,13 @@ class Result implements IDataSource
/**
* Like fetch(), but returns only first field.
* @return mixed value on success, null if no next record
* @return mixed value on success, false if no next record
*/
final public function fetchSingle()
{
$row = $this->getResultDriver()->fetch(true);
if ($row === null) {
return null;
return false;
}
$this->fetched = true;
$this->normalize($row);

View File

@@ -18,6 +18,9 @@ $conn->loadFile(__DIR__ . "/data/$config[system].sql");
// fetch a single value
$res = $conn->query('SELECT [title] FROM [products] ORDER BY [product_id]');
Assert::same('Chair', $res->fetchSingle());
Assert::same('Table', $res->fetchSingle());
Assert::same('Computer', $res->fetchSingle());
Assert::false($res->fetchSingle());
// fetch complete result set