Edit report at https://bugs.php.net/bug.php?id=68997&edit=1
ID: 68997
Updated by: dharman@php.net
Reported by: maxm at corp dot badoo dot com
Summary: var_dump(mysqli) doesn't work with MYSQLI_ASYNC
queries
-Status: Open
+Status: Closed
-Type: Documentation Problem
+Type: Bug
Package: MySQLi related
Operating System: Linux
PHP Version: 5.5.21
-Assigned To:
+Assigned To: dharman
Block user comment: N
Private report: N
New Comment:
I am going to change this to a bug. If I understand correctly this has been fixed a few years ago.
If not, please reopen this bug on https://github.com/php/php-src/issues.
Previous Comments:
------------------------------------------------------------------------
[2015-02-06 16:16:23] maxm at corp dot badoo dot com
Description:
------------
If I take code from http://php.net/manual/en/mysqli.poll.php and add
2 var_dump's/print_r's (see my code), that code starts to generate "Commands out of
sync; you can't run this command now"
So as I understand we can't use var_dump() for the connection at this stage. It would be great
to describe it in the documentation.
Test script:
---------------
<?php
$link1 = mysqli_init();
mysqli_real_connect($link1, 'dbm1.d4','developer','developerovich');
mysqli_query($link1, "SELECT version() as ver", MYSQLI_ASYNC);
$all_links = array($link1);
$processed = 0;
do {
ââââ$links = $errors = $reject = array();
ââââforeach ($all_links as $link) {
ââââââââ$links[] = $errors[] = $reject[] = $link;
ââââ}
var_dump($links); // !!! this var_dump cause the problem
ââââif (!mysqli_poll($links, $errors, $reject, 1)) {
ââââââââcontinue;
ââââ}
print_r($links); // it shows us that we have text in the$mysqli->error object
ââââforeach ($links as $link) {
ââââââââif ($result = $link->reap_async_query()) {
ââââââââââââprint_r($result->fetch_assoc());
ââââââââââââif (is_object($result))
ââââââââââââââââmysqli_free_result($result);
ââââââââ} else die(sprintf("MySQLi Error: %s",
mysqli_error($link)));
ââââââââ$processed++;
ââââ}
} while ($processed < count($all_links));
Expected result:
----------------
So, as I understand, we can't call var_dump()/ print_r between:
mysqli_query(...., MYSQLI_ASYNC) and mysqli_poll(...)
It would be great to cover this nuance in the documentation. Or as a better option, fix
var_dump/print_r() to work correctly with mysqli connections with async requests.
Actual result:
--------------
last print_r shows this:
Array
(
[0] => mysqli Object
(
[affected_rows] => -1
[client_info] => mysqlnd 5.0.11-dev - 20120503 - $Id:
7f4b7f0657d4ab15d8fdac13f23f696de5283a89 $
[client_version] => 50011
[connect_errno] => 0
[connect_error] =>
[errno] => 2014
[error] => Commands out of sync; you can't run this command now
[error_list] => Array
(
[0] => Array
(
[errno] => 2014
[sqlstate] => HY000
[error] => Commands out of sync; you can't run this command now
)
)
[field_count] => 0
[host_info] => XXXXX via TCP/IP
[info] =>
[insert_id] => 0
[server_info] => 5.5.28-log
[server_version] => 50528
[stat] =>
[sqlstate] => HY000
[protocol_version] => 10
[thread_id] => 268564296
[warning_count] => 0
)
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68997&edit=1