From: exaton at free dot fr
Operating system: Windows XP Pro SP2
PHP version: 5.2.1
PHP Bug Type: PDO related
Bug description: Suddenly binding as many vars as there are *identical*
prepared tokens
Description:
------------
I have just upgraded from PHP 5.2.0 to PHP 5.2.1, and one of my scripts
has broken on the following point (note, the backend database is
PostgreSQL 8.1.5) :
Consider this prepared statement query, automatically generated as part of
a basic search engine operating on a table of shops :
SELECT indx, name, town FROM shops WHERE enabled AND (lower(name) LIKE
:word0 OR lower(address) LIKE :word0 OR lower(town) LIKE :word0 OR
lower(company) LIKE :word0 OR lower(description) LIKE :word0) ORDER BY
name;
You notice that 5 ':word0' tokens are defined. I then proceed to bind
':word0' to a certain value (individual $word taken from a search field),
*a single time* of course :
$shops -> bindValue(':word'.$i, '%'.$word.'%'); // $i = 0
Up to PHP 5.2.0, this worked as expected. Now in PHP 5.2.1 I am getting a
PDOException : "SQLSTATE[HY093]: Invalid parameter number: number of bound
variables does
not match number of tokens".
To work around this problem, I indeed have to call bindValue() as many
times as there are tokens (5 in this example), even though those tokens
are identical. As a consequence, the name of the extra *fictitious* bound
tokens does not matter, except that binding 5 times the same token name
(e.g. 5 times ':word0') does not work. But binding ':word0' to ':word4'
does, for instance.
I have noticed some similarity with PHP bug #33886, but I believe this to
be a slightly different situation (bindValue() as opposed to on-the-fly
binding), not to mention that it breaks existing scripts.
Thank you in advance for your feedback on this issue.
--
Edit bug report at http://bugs.php.net/?id=40417&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=40417&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=40417&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=40417&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40417&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=40417&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40417&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40417&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40417&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40417&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40417&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=40417&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=40417&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40417&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40417&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40417&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40417&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40417&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40417&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40417&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40417&r=mysqlcfg