|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-06-07 10:12 UTC] uw@php.net
-Status: Open
+Status: Not a bug
[2013-06-07 10:12 UTC] uw@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
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