From: bugs dot php dot net at andrewprendergast dot com Operating system: Linux Red Hat EL PHP version: 5.2.1RC2 PHP Bug Type: PDO related Bug description: SQL IN (...) and = ANY (...) not supported by PDO
Description: ------------ PDO doesn't allow one to SELECT or DELETE groups of records based on their primary key. Specifically, the SQL clauses WHERE ... IN (...) and WHERE ... = ANY (...) does not work for more than one record. As a workaround I can construct an SQL query and execute it myself but that defeats the niceness of PDO. Reproduce code: --------------- 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))) NB: The intention of the 2nd example is that when binding an array, it seems natural that PDO would assume its part of an IN or =ANY clause and convert it into a bunch of comma separated keys automagically. Some of the higher level PDO based O/R abstractions currently bouncing around like Doctrine would then be able to support (without any modificaiton) queries that affect multiple records. Expected result: ---------------- Two records should be loaded. Actual result: -------------- One record is loaded. -- Edit bug report at http://bugs.php.net/?id=40048&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40048&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40048&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40048&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40048&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40048&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40048&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40048&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40048&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40048&r=support Expected behavior: http://bugs.php.net/fix.php?id=40048&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40048&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40048&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40048&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40048&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40048&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40048&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40048&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40048&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40048&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40048&r=mysqlcfg