ID: 45169
Comment by: lapo at lapo dot it
Reported By: ian dot lewis at mediatel dot co dot uk
Status: Open
Bug Type: Feature/Change Request
Operating System: Linux Ubuntu
PHP Version: 5.2.6
New Comment:
You problem is probably that you used "'" for bound strings when they
should not be used (and thus they were considered constant strings),
but
I do agree on the issue that the error could be more informative.
Previous Comments:
------------------------------------------------------------------------
[2008-06-04 11:24:04] ian dot lewis at mediatel dot co dot uk
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 this bug report at http://bugs.php.net/?id=45169&edit=1