ID: 40417 Updated by: [EMAIL PROTECTED] Reported By: exaton at free dot fr -Status: Open +Status: Feedback Bug Type: PDO related Operating System: Windows XP Pro SP2 PHP Version: 5.2.1 New Comment:
Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Previous Comments: ------------------------------------------------------------------------ [2007-02-09 16:39:14] exaton at free dot fr 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 this bug report at http://bugs.php.net/?id=40417&edit=1