mirror of
https://github.com/dg/dibi.git
synced 2025-08-02 12:21:06 +02:00
fetchSingle returns FALSE
This commit is contained in:
@@ -161,7 +161,7 @@ class DataSource implements IDataSource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Like fetch(), but returns only first field.
|
* 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()
|
public function fetchSingle()
|
||||||
{
|
{
|
||||||
|
@@ -311,7 +311,7 @@ class Fluent implements IDataSource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Like fetch(), but returns only first field.
|
* 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()
|
public function fetchSingle()
|
||||||
{
|
{
|
||||||
|
@@ -179,13 +179,13 @@ class Result implements IDataSource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Like fetch(), but returns only first field.
|
* 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()
|
final public function fetchSingle()
|
||||||
{
|
{
|
||||||
$row = $this->getResultDriver()->fetch(true);
|
$row = $this->getResultDriver()->fetch(true);
|
||||||
if ($row === null) {
|
if ($row === null) {
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
$this->fetched = true;
|
$this->fetched = true;
|
||||||
$this->normalize($row);
|
$this->normalize($row);
|
||||||
|
@@ -18,6 +18,9 @@ $conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
|||||||
// fetch a single value
|
// fetch a single value
|
||||||
$res = $conn->query('SELECT [title] FROM [products] ORDER BY [product_id]');
|
$res = $conn->query('SELECT [title] FROM [products] ORDER BY [product_id]');
|
||||||
Assert::same('Chair', $res->fetchSingle());
|
Assert::same('Chair', $res->fetchSingle());
|
||||||
|
Assert::same('Table', $res->fetchSingle());
|
||||||
|
Assert::same('Computer', $res->fetchSingle());
|
||||||
|
Assert::false($res->fetchSingle());
|
||||||
|
|
||||||
|
|
||||||
// fetch complete result set
|
// fetch complete result set
|
||||||
|
Reference in New Issue
Block a user