Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Bug #11179 Prepared statements with named placeholders fails if extra values
Submitted: 2007-05-30 18:28 UTC
From: mosheortov Assigned: quipo
Status: Closed Package: MDB2 (version 2.4.1)
PHP Version: 5.2.0 OS: Linux + Windows
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 16 - 3 = ?

 
 [2007-05-30 18:28 UTC] mosheortov (Moshe Ortov)
Description: ------------ I have code which takes multiple posted values and figures out which SQL to execute. The net result is the array of values I have exceeds the number of named placeholders actually required. In previous versions the extra ones were ignored, but now they are not and they generate an error as the example shows. I would have expected unused values should be ignored rather than causing an error - this was the previous behavior. Test script: --------------- <?php require_once("database.php"); $paramTypes = array("name" => "text", "active" => "boolean", "anglerno" => "integer"); $dbPrep =& $dbHandle->prepare("UPDATE angler SET name=:name, active=:active WHERE anglerno=:anglerno", $paramTypes); $dbRes =& $dbPrep->execute(array("name" => "A Neeone", "active" => "true", "anglerno" => "37", "fred"=>"jhhjkf")); if (PEAR::isError($dbRes)) { //errors - extra item 'fred' causes error var_dump($dbRes); echo $dbRes->getUserinfo(); } else { echo "statement 1 is OK\n"; } $dbRes =& $dbPrep->execute(array("name" => "A Neeone", "active" => "true", "anglerno" => "37")); if (PEAR::isError($dbRes)) { //is OK - we don't get here - var_dump($dbRes); echo $dbRes->getUserinfo(); } else { echo "statement 2 is OK\n"; } ?> Expected result: ---------------- $ php tester.php statement 1 is OK statement 2 is OK Actual result: -------------- $ php tester.php execute: [Error message: Binding Values failed with message: MDB2 Error: not found] statement 2 is OK

Comments

 [2007-06-02 09:07 UTC] quipo (Lorenzo Alberton)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.