From:  alekscee@gmx.de ("alekscee")
Date:  10 May 2017 15:43:52 Hong Kong Time
Newsgroup:  news.php.net/php.pear.bugs
Subject:  

[PEAR-BUG] Bug #17207 [Com]: prepare()d statement with MDB2_PREPARE_MANIP fails to execute

NNTP-Posting-Host:  null

Edit report at http://pear.php.net/bugs/bug.php?id=17207&edit=1

 ID:               17207
 Comment by:       alekscee
 Reported By:      alekscee at gmx dot de
 Summary:          prepare()d statement with MDB2_PREPARE_MANIP fails to
                   execute
 Status:           Open
 Type:             Bug
 Package:          MDB2_Driver_mysqli
 Operating System: OS X - Snow Leopard
 Package Version:  1.4.1
 PHP Version:      5.3.0
 New Comment:

I have the same behavior with Ubuntu 16 LTS when using the official
packages from the release for PHP7 and MDB2.


Previous Comments:
------------------------------------------------------------------------

[2012-03-07 16:18:13] thomas_glaessle

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:
--------
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.

------------------------------------------------------------------------

[2010-04-21 19:34:44] holsen

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]

------------------------------------------------------------------------

[2010-03-09 00:24:45] szbeamaroo

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

------------------------------------------------------------------------


-- 
Edit this bug report at http://pear.php.net/bugs/bug.php?id=17207&edit=1