From: zuohaocheng1022 at gmail dot com Operating system: Mac OS X PHP version: 5.5.0RC1 Package: PDO related Bug Type: Bug Bug description:Fails if named parameters appears more than once
Description: ------------ Pdo-mysql prepared statements execution fails when one named parameter appears more than once in a SQL statement. This problem will disappear if set PDO::ATTR_EMULATE_PREPARES to true. Test script: --------------- //CREATE TABLE `posts` ( // `id` int(10) unsigned NOT NULL AUTO_INCREMENT, // `name` VARCHAR(255), // `body` TEXT //); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); // :search appears twice here $stmt = $pdo->prepare('SELECT id FROM posts WHERE name LIKE :search OR body LIKE :search'); $s = 'blablah'; $stmt->bindParam(':search', $s); $stmt->execute(); // This step throws an exception: Error: SQLSTATE[HY093]: Invalid parameter number // $stmt->execute([':search'=>$s]); will throw it too $result = $stmt->fetch(); Expected result: ---------------- No exceptions. Actual result: -------------- $stmt>execute fails. Error: SQLSTATE[HY093]: Invalid parameter number -- Edit bug report at https://bugs.php.net/bug.php?id=64875&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64875&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64875&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64875&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64875&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64875&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64875&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64875&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64875&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64875&r=support Expected behavior: https://bugs.php.net/fix.php?id=64875&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64875&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64875&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64875&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64875&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64875&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64875&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64875&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64875&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64875&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64875&r=mysqlcfg