From: ian dot lewis at mediatel dot co dot uk
Operating system: Linux Ubuntu
PHP version: 5.2.6
PHP Bug Type: PDO related
Bug description: PDO Some error messages are uninformative
Description:
------------
The error message is given below.
PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound
variables does not match number of tokens in xxx.php
It would be - extremely - helpful if the error message contained a list of
the matched tokens or some information on where the token substitution
failed.
Reproduce code:
---------------
$query = "SELECT *
FROM example_table et
WHERE start_date BETWEEN ':sStartDate' AND ':sEndDate'
AND user_id = :iId"
<snip prepare statement>
$sStatement->bindParam(':iId', $iUserId, PDO::PARAM_INT);
$sStatement->bindParam(':sStartDate', $sStartDate, PDO::PARAM_STR);
$sStatement->bindParam(':sEndDate', $sEndDate, PDO::PARAM_STR);
$sStatement->execute();
The error PDOException: SQLSTATE[HY093]: Invalid parameter number: number
of bound variables does not match number of tokens in xxx.php
Expected result:
----------------
Expect to see either no error because it worked or a message such as
PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound
variables does not match number of tokens in xxx.php. Cannot find token
:sStartDate
Actual result:
--------------
PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound
variables does not match number of tokens in xxx.php
--
Edit bug report at http://bugs.php.net/?id=45169&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45169&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45169&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45169&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45169&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45169&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45169&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45169&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45169&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45169&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45169&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45169&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45169&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45169&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45169&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45169&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45169&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45169&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45169&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45169&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45169&r=mysqlcfg