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

Bug #17207 prepare()d statement with MDB2_PREPARE_MANIP fails to execute
Submitted: 2010-03-09 05:24 UTC
From: szbeamaroo Assigned:
Status: Open Package: MDB2_Driver_mysqli (version 1.4.1)
PHP Version: 5.3.0 OS: OS X - Snow Leopard
Roadmaps: (Not assigned)    
Subscription  


 [2010-03-09 05:24 UTC] szbeamaroo (sam Beam)
Description: ------------ When specifying MDB2_PREPARE_MANIP when preparing an INSERT statement, the subsequent execute() fails, with mysqli_stmt_execute() returning 0 instead of 1. Leaving the 3rd parameter to prepare() out, the statement will execute. However this results in the return value from execute() being an MDB2_Result_Common object instead of an integer, which breaks expectations. This may be an underlying driver problem, as the same code below works as expected on Linux. $ mysql -V mysql Ver 14.14 Distrib 5.1.44, for apple-darwin10.2.0 (i386) using readline 5.1 Test script: --------------- $mdb2 =& MDB2::connect(DB_DSN); $mdb2->setOption('debug',2); $sth = $mdb2->prepare('INSERT INTO numbers (number) VALUES (?)', array('integer'), MDB2_PREPARE_MANIP); $sth->execute(1); $sth->execute(8); var_dump($mdb2->getDebugOutput()); Expected result: ---------------- successful insert of numbers to the numbers table, and output from the debug line. Actual result: -------------- here is a backtrace of the error caught via my PEAR_ERROR_CALLBACK handler - pear_error_handler)) called at [/usr/lib/php/PEAR.php:955] #2 PEAR_Error->PEAR_Error(MDB2 Error: unknown error, -1, 16, pear_error_handler, _execute: [Error message: Unable to execute statement] [Last executed query: INSERT INTO numbers (number) VALUES (?)] [Native code: 0] ) called at [/usr/lib/php/MDB2.php:973] #3 MDB2_Error->MDB2_Error(, 16, pear_error_handler, _execute: [Error message: Unable to execute statement] [Last executed query: INSERT INTO numbers (number) VALUES (?)] [Native code: 0] ) called at [/usr/lib/php/PEAR.php:564] #4 PEAR->raiseError(, , , , _execute: [Error message: Unable to execute statement] [Last executed query: INSERT INTO numbers (number) VALUES (?)] [Native code: 0] , MDB2_Error, 1) called at [/usr/lib/php/MDB2.php:1442] #5 MDB2_Driver_Common->raiseError(, , , Unable to execute statement, _execute) called at [/usr/lib/php/MDB2/Driver/mysqli.php:1574] #6 MDB2_Statement_mysqli->_execute(1, ) called at [/usr/lib/php/MDB2.php:4065] #7 MDB2_Statement_Common->execute(1) called at [/Users/sbeam/Sites/dnl/util/test.php:10

Comments

 [2010-04-21 23:34 UTC] holsen (Henrik Olsen)
Using Mac OS X 10.6.3 PHP 5.3.1 MySQL 5.1.44 MDB2 2.5.0b2 beta MDB2_Driver_mysqli 1.5.0b2 beta I see a variant (of prepared statements) fail as well. I think it might be related to the PHP 5.3 change for call_user_func_array. See the following links: http://www.n8williams.com/devblog/php/prepared-statement-errors-with-php-5-3-and-mysqli-call_user_func_array-returns-null http://bugs.php.net/43568 My failing example is $this->db->autoExecute('locks', $data, MDB2_AUTOQUERY_INSERT); _execute: [Error message: Unable to execute statement] [Last executed query: INSERT INTO locks (host, pid, name, created) VALUES (?, ?, ?, ?)] [Native code: 0]
 [2012-03-07 21:18 UTC] thomas_glaessle (Thomas Gläßle)
Running on: -------- PEAR Version: 1.9.0 PHP Version: 5.3.2-1ubuntu4.14 Zend Engine Version: 2.3.0 Running on: Linux core-problem 2.6.32-39-generic #86-Ubuntu SMP Mon Feb 13 21:50:08 UTC 2012 x86_64 MDB2 2.4.1 stable MDB2_Driver_mysqli 1.4.1 stable -------- The prepared statements using MDB2_PREPARE_MANIP fail for me as well. I have only tried UPDATE query so far: Minimal example: -------- <?php require_once('MDB2.php'); $db =& MDB2::connect($dsn); $db->setErrorHandling(PEAR_ERROR_DIE); $stmt = $db->prepare("UPDATE `user` SET `session`=?", null, MDB2_PREPARE_MANIP); $success = $stmt->execute(array('x')); ?> -------- Output: -------- MDB2 Error: unknown error -------- When enabling warnings in MDB2/Driver/mysqli.php and printing the mysqli-error via mysqli_stmt_error(), i get: -------- Warning: Parameter 3 to mysqli_stmt_bind_param() expected to be a reference, value given in /usr/share/php/MDB2/Driver/mysqli.php on line 1523 MDB2 Error: unknown error -------- Therefore Henrik seems to be right, that the problem is related to the usage of call_user_func_array(). I have created a minimal-intrusive ad-hoc patch, which solves the problem in my case. It is not very elegant though.
 [2017-05-10 07:37 UTC] alekscee (Alexander Palm)
I have the same behavior with Ubuntu 16 LTS when using the official packages from the release for PHP7 and MDB2.