php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68997 var_dump(mysqli) doesn't work with MYSQLI_ASYNC queries
Submitted: 2015-02-06 16:16 UTC Modified: 2017-10-24 07:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: maxm at corp dot badoo dot com Assigned:
Status: Open Package: MySQLi related
PHP Version: 5.5.21 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: maxm at corp dot badoo dot com
New email:
PHP Version: OS:

 

 [2015-02-06 16:16 UTC] 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
        )

)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-16 14:08 UTC] tony2001@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: andrey
 [2017-10-24 07:21 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: andrey +Assigned To:
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 11:01:30 2019 UTC