#45169 [Com]: PDO Some error messages are uninformative

From: Date: Thu, 24 Dec 2009 10:43:58 +0000
Subject: #45169 [Com]: PDO Some error messages are uninformative
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-146088@lists.php.net to get a copy of this message
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

« previous php.bugs (#146088) next »