[PHP-BUG] Bug #51559 [NEW]: SQLSTATE[HY093]: Invalid parameter number (error in docs or calculation)
[email protected] ("frode at seria dot no")
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
From:
Operating system: Debian Lenny
PHP version: 5.2.13
Package: PDO related
Bug Type: Bug
Bug description:SQLSTATE[HY093]: Invalid parameter number (error in docs or calculation)
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 bug report at http://bugs.php.net/bug.php?id=51559&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51559&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51559&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51559&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=51559&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51559&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51559&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51559&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51559&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51559&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51559&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51559&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51559&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51559&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51559&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51559&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51559&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51559&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51559&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51559&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51559&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51559&r=mysqlcfg