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

Bug #10239 execute() misinterprets MySQL's user defined variables
Submitted: 2007-03-01 18:13 UTC Modified: 2007-03-10 04:58 UTC
From: mjohnson at pitsco dot com Assigned: quipo
Status: Closed Package: MDB2 (version 2.3.0)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2007-03-01 18:13 UTC] mjohnson at pitsco dot com (Michael Johnson)
Description: ------------ When using prepared statements, MySQL user defined variables are mis-interpreted as named place holders. When dealing with more complicated situations, the error is different. We have a sort of query library we use internally and when running the same query as the test script the result is: MDB2 Error: syntax error _doquery: [Error message: Could not execute statement] [Last executed query: PREPARE MDB2_STATEMENT_mysql_ef8a43da87c7f66c71cbc6e7e1427102 FROM 'SELECT @x?'] [Native code: 1064] [Native message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1] (note the variables being passed in here are overkill for query, which I substituted in for testing) Test script: --------------- <?php require_once('MDB2.php'); $dsn = 'mysql://test:testpassword@localhost/test'; $db =& MDB2::singleton($dsn); $prep =& $db->prepare('SELECT @x:=5'); $res = $prep->execute(); if (MDB2::isError($res)) { echo "Error.\n"; echo $res->message . "\n"; echo $res->userinfo . "\n"; } ?> Expected result: ---------------- Expect to see nothing. Actual result: -------------- Error. MDB2 Error: not found _execute: [Error message: Unable to bind to missing placeholder: SELECT @x:=5] [Native code: ] [Native message: ]

Comments

 [2007-03-10 04:58 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.
 [2008-07-13 15:42 UTC] soladon (Soladon Shoosh)
I am using the following: MDB2 2.5.0b1 beta MDB2_Driver_mysql 1.5.0b1 beta and the error still exists. Just try the following: <?php require_once('MDB2.php'); $dsn = 'mysql://username:password@localhost/'; $db =& MDB2::singleton($dsn); $prep =& $db->prepare('SELECT @x:=5'); $res = $prep->execute(); if (MDB2::isError($res)) { echo "Error.\n"; echo $res->message . "\n"; echo $res->userinfo . "\n"; } ?> Any ideas what is wrong?