note 86776 added to pdo.query

From: Date: Mon, 03 Nov 2008 10:43:25 +0000
Subject: note 86776 added to pdo.query
Groups: php.notes 
Request: Send a blank email to php-notes+get-146079@lists.php.net to get a copy of this message
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; ---- Server IP: 210.51.44.91 Probable Submitter: 61.172.54.252 ---- Manual Page -- http://www.php.net/manual/en/pdo.query.php Edit -- https://master.php.net/note/edit/86776 Del: integrated -- https://master.php.net/note/delete/86776/integrated Del: useless -- https://master.php.net/note/delete/86776/useless Del: bad code -- https://master.php.net/note/delete/86776/bad+code Del: spam -- https://master.php.net/note/delete/86776/spam Del: non-english -- https://master.php.net/note/delete/86776/non-english Del: in docs -- https://master.php.net/note/delete/86776/in+docs Del: other reasons-- https://master.php.net/note/delete/86776 Reject -- https://master.php.net/note/reject/86776 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#146079) next »