note 72130 rejected from ref.pdo by nlopess
| From: | nlopess@php.net | Date: | Thu, 04 Jan 2007 15:31:14 +0000 |
| Subject: | note 72130 rejected from ref.pdo by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-121288@lists.php.net to get a copy of this message | ||
Note Submitter: ap at andrewprendergast dot com
----
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.