|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-04-22 02:51 UTC] felipe@php.net
-Package: PDO related
+Package: Documentation problem
[2010-10-20 07:04 UTC] kalle@php.net
[2010-10-20 07:04 UTC] kalle@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: kalle
[2010-10-20 07:04 UTC] kalle@php.net
[2020-02-07 06:09 UTC] phpdocbot@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 05:00:01 2025 UTC |
Description: ------------ I get the following PDOException when executing a prepared statement: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined This behaviour changed in PHP after version 5.2.0 and a related issue #40417 exists. However, nothing in the documentation specifies that you can't bind MORE variables than are used in the SQL. For example if you call $statement->execute($_POST), you might bind more variables than are used in the SQL. Test script: --------------- $params = array(':key1' => 'value1', ':key2' => 'value2'); $stmt = $db->prepare('SELECT * FROM table WHERE id=:key1'); $stmt->execute($params); Expected result: ---------------- I expect this to succeed. We relied on this feature in much of our old code working up to PHP version 5.2.0, but have made a workaround in our DB layer which parses the SQL. Actual result: -------------- PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined