ID:               35203
 Updated by:       [EMAIL PROTECTED]
 Reported By:      kristaps dot kaupe at itrisinajumi dot lv
-Status:           Closed
+Status:           Bogus
 Bug Type:         MySQLi related
 Operating System: Gentoo Linux
 PHP Version:      5.0.5


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

[2005-11-14 10:46:00] kristaps dot kaupe at itrisinajumi dot lv

Ok, got the point. Additional $db->next_result() with
$db->multi_query() was solution. My fault, sorry!

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

[2005-11-13 18:40:19] [EMAIL PROTECTED]

fixed status

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

[2005-11-13 18:36:55] [EMAIL PROTECTED]

When a stored procedure returns a resultset, MySQL returns at least two
resultsets: first for the SELECT CALL inside the stored procedure. 2nd
for the call of the stored procedure itself (2nd usually is only an OK
or ERR packet)

mysqli_query fetches only one resultset, the second is still on socket:
subsequent mysqli_ calls will fail, cause the sockets is still blocked.

Therefore you should use mysqli_next_result and mysqli_multi_query
instead.

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

[2005-11-13 16:33:03] kristaps dot kaupe at itrisinajumi dot lv

Status change to "Open".

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

[2005-11-13 15:55:15] kristaps dot kaupe at itrisinajumi dot lv

Why I should use mysqli_multi_query()? Where is it documented, that I
should use mysqli_multi_query() for stored procedures?

But the following code with mysqli_multi_query() doesn't work either:

-------
// $db is mysqli object
if ($db->multi_query('CALL test_proc(1); CALL test_proc(1);')) {
    if ($result = $db->store_result()) {
        $res = $result->fetch_assoc();
        print_r($res);
        $result->close();
    }
    else
        echo '<br />No result!<br />';
    $db->next_result();
    if ($result = $db->store_result()) {
        $res = $result->fetch_assoc();
        print_r($res);
        $result->close();
    }
    else
        echo '<br />No result<br />';
}
else
    echo '<br />'.$db->error.'<br />';
-----

Produces the following output:
-----
Array
(
    [id] => 1
    [txt] => test1
)

No result
-----

(Expected was two identical results)

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/35203

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

Reply via email to