note 72130 added to ref.pdo
| From: | ap at andrewprendergast dot com | Date: | Thu, 04 Jan 2007 04:01:33 +0000 |
| Subject: | note 72130 added to ref.pdo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121265@lists.php.net to get a copy of this message | ||
Quick heads up that PDO doesn't allow one to SELECT or DELETE groups of records based on their
primary key.
For example, the following should return the records with ID 1 & 2:
$dbh = new PDO('mysql:host=localhost;dbname=mobop', "root", "");
$stmt = $dbh->prepare("SELECT * FROM news_item WHERE news_item_id IN(?)");
if ( $stmt->execute(array("1, 2")) )
while ( ($row = $stmt->fetch()) )
print_r($row);
But it doesn't. The following execute statement fails as well:
$stmt->execute(array(array(2,1)))
IE, the SQL clauses WHERE ... IN (...) and WHERE ... = ANY (...) does not work with PDO for more
than one record.
----
Server IP: 203.202.10.60
Probable Submitter: 59.167.194.156
----
Manual Page -- http://www.php.net/manual/en/ref.pdo.php
Edit -- https://master.php.net/note/edit/72130
Del: integrated -- https://master.php.net/note/delete/72130/integrated
Del: useless -- https://master.php.net/note/delete/72130/useless
Del: bad code -- https://master.php.net/note/delete/72130/bad+code
Del: spam -- https://master.php.net/note/delete/72130/spam
Del: non-english -- https://master.php.net/note/delete/72130/non-english
Del: in docs -- https://master.php.net/note/delete/72130/in+docs
Del: other reasons-- https://master.php.net/note/delete/72130
Reject -- https://master.php.net/note/reject/72130
Search -- https://master.php.net/manage/user-notes.php