Bug #51559 [Opn->Csd]: SQLSTATE[HY093]: Invalid parameter number (error in docs or calculation)
| From: | kalle@php.net | Date: | Wed, 20 Oct 2010 05:04:36 +0000 |
| Subject: | Bug #51559 [Opn->Csd]: SQLSTATE[HY093]: Invalid parameter number (error in docs or calculation) | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5270@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51559&edit=1
ID: 51559
Updated by: kalle@php.net
Reported by: frode at seria dot no
Summary: SQLSTATE[HY093]: Invalid parameter number (error in
docs or calculation)
-Status: Open
+Status: Closed
Type: Bug
Package: Documentation problem
Operating System: Debian Lenny
PHP Version: 5.2.13
-Assigned To:
+Assigned To: kalle
Block user comment: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2010-10-20 07:04:30] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=304528
Log: Fixed bug #51559 (SQLSTATE[HY093]: Invalid parameter number (error
in docs or calculation))
------------------------------------------------------------------------
[2010-04-15 11:30:06] frode at seria dot no
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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51559&edit=1