note 66512 added to function.mysqli-multi-query
| From: | gperosio at osu1 dot php dot net | Date: | Wed, 24 May 2006 20:42:44 +0000 |
| Subject: | note 66512 added to function.mysqli-multi-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111958@lists.php.net to get a copy of this message | ||
I failed to execute two calls to stored procedure in mysql, because next_result and use result
returns false.
I means:
$ok = mysqli_multi_query($this->dbc,"CALL sp1('param'); CALL
sp2('param');");
but result from sp2 never returns records, neither a resultset.
Then I found this note:
---
[13 Nov 2005 6:36pm UTC] georg@php.net
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.
---
And then, this solutions works, but I guess this is a bug to correct.
solution:
mysqli_next_result($this->dbc);
$rs = mysqli_store_result($this->dbc);
if (!$rs)
mysqli_next_result($this->dbc);
$rs = mysqli_store_result($this->dbc);
if ($rs)
...
----
Server IP: 201.216.232.3
Probable Submitter: 200.51.132.44
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mysqli-multi-query.php
Edit -- http://master.php.net/note/edit/66512
Del: integrated -- http://master.php.net/note/delete/66512/integrated
Del: useless -- http://master.php.net/note/delete/66512/useless
Del: bad code -- http://master.php.net/note/delete/66512/bad+code
Del: spam -- http://master.php.net/note/delete/66512/spam
Del: non-english -- http://master.php.net/note/delete/66512/non-english
Del: in docs -- http://master.php.net/note/delete/66512/in+docs
Del: other reasons-- http://master.php.net/note/delete/66512
Reject -- http://master.php.net/note/reject/66512
Search -- http://master.php.net/manage/user-notes.php