1
0
mirror of https://github.com/dg/dibi.git synced 2025-07-10 00:56:24 +02:00

fetchSingle returns FALSE

This commit is contained in:
David Grudl
2018-05-17 13:27:45 +02:00
parent 70b1e08d83
commit 7a775aad4f
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