note 86776 rejected from pdo.query by thiago
| From: | thiago@php.net | Date: | Mon, 03 Nov 2008 11:34:26 +0000 |
| Subject: | note 86776 rejected from pdo.query by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146080@lists.php.net to get a copy of this message | ||
Note Submitter: yarco dot w at gmail dot com
----
It's not true cause PDO::query would also return false when sql error.
So you can't the following code:
return $pdo->query($sql)->fetch();
You would get the following error information:
PHP Fatal error: Call to a member function fetch() on a non-object
I think it is bug cause if you add check, the code would be ugly to read.
return $result = $pdo->query($sql) ? $result->fetch() : false;