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 23:13 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 23: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 09:58 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2008-07-13 20:42 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!