Req #45169 [Opn]: Some error messages are uninformative
| From: | cmb@php.net | Date: | Fri, 27 Aug 2021 12:59:26 +0000 |
| Subject: | Req #45169 [Opn]: Some error messages are uninformative | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-236117@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=45169&edit=1
ID: 45169
Updated by: cmb@php.net
Reported by: ian dot lewis at mediatel dot co dot uk
Summary: Some error messages are uninformative
Status: Open
Type: Feature/Change Request
Package: PDO related
Operating System: Linux Ubuntu
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
> 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.
While that probably can be done for emulated prepares, it cannot
be done for native prepares (because these are not processed by
PHP, so we rely on what the server reports), and it seems to me
that the latter are more widely used.
Anyhow, 18 upvotes, so I'm leaving this open.
Previous Comments:
------------------------------------------------------------------------
[2009-12-24 10:43:58] lapo at lapo dot it
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.
------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=45169&edit=1