Doc #68997 [NEW]: var_dump(mysqli) doesn't work with MYSQLI_ASYNC queries
| From: | maxm at corp dot badoo dot com | Date: | Fri, 06 Feb 2015 16:16:24 +0000 |
| Subject: | Doc #68997 [NEW]: var_dump(mysqli) doesn't work with MYSQLI_ASYNC queries | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-11929@lists.php.net to get a copy of this message | ||
From: maxm at corp dot badoo dot com
Operating system: Linux
PHP version: 5.5.21
Package: MySQLi related
Bug Type: Documentation Problem
Bug description:var_dump(mysqli) doesn't work with MYSQLI_ASYNC queries
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 bug report at https://bugs.php.net/bug.php?id=68997&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68997&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68997&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68997&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68997&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68997&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68997&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68997&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68997&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68997&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68997&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68997&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68997&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68997&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68997&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68997&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68997&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68997&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68997&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68997&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68997&r=mysqlcfg