# [Fwd: fetch() returning false for empty datasets]

- Thread: https://externals.io/message/24033
- Original archive: https://news-web.php.net/php.internals/24033
- Started by Lukas Smith on 2006-06-09T12:22:14+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #24033 — Lukas Smith — 2006-06-09T12:22:14+00:00

URL: https://externals.io/message/24033#24033

Forwarding here.
Maybe it got lost inbetween the spam attacks, maybe its just not 
interesting but lets open up the topic to a larger audience :)

-------- Original Message --------
Subject: fetch() returning false for empty datasets
Date: Mon, 05 Jun 2006 11:41:12 +0200
From: lsmith@php.net (Lukas Smith)
To: pecl-dev@lists.php.net
Newsgroups: php.pecl.dev

Hi,

the following script outputs "false" (at least on whatever pdo version
is bundled with 5.1.4):

$sql = 'SELECT 1 FROM dual WHERE 1=0';
$stmt = $dbh->query($sql);
var_dump($stmt->fetch(PDO::FETCH_ASSOC));

all other RDBMS extension we have return null in this case, which seems
to be the right thing too ..

regards,
Lukas

---

## #24034 — Pierre — 2006-06-09T12:24:13+00:00

URL: https://externals.io/message/24033#24034 · In reply to: #24033

> Forwarding here.
> Maybe it got lost inbetween the spam attacks, maybe its just not
> interesting but lets open up the topic to a larger audience :)
>
> -------- Original Message --------
> Subject: fetch() returning false for empty datasets
> Date: Mon, 05 Jun 2006 11:41:12 +0200
> From: lsmith@php.net (Lukas Smith)
> To: pecl-dev@lists.php.net
> Newsgroups: php.pecl.dev
>
> Hi,
>
> the following script outputs "false" (at least on whatever pdo version
> is bundled with 5.1.4):
>
> $sql = 'SELECT 1 FROM dual WHERE 1=0';
> $stmt = $dbh->query($sql);
> var_dump($stmt->fetch(PDO::FETCH_ASSOC));
>
> all other RDBMS extension we have return null in this case, which seems
> to be the right thing too ..

I have to agree here. `NULL` defines this situation perfectly, false
being used for errors (strict false, === FALSE).

--Pierre
