Doc #68997 [Opn->Asn]: var_dump(mysqli) doesn't work with MYSQLI_ASYNC queries

From: Date: Mon, 16 Feb 2015 14:08:22 +0000
Subject: Doc #68997 [Opn->Asn]: var_dump(mysqli) doesn't work with MYSQLI_ASYNC queries
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-11950@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68997&edit=1 ID: 68997 Updated by: tony2001@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: Assigned Type: Documentation Problem Package: MySQLi related Operating System: Linux PHP Version: 5.5.21 -Assigned To: +Assigned To: andrey Block user comment: N Private report: N 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

« previous php.doc.bugs (#11950) next »