note 66512 deleted from function.mysqli-multi-query by bjori
| From: | bjori@php.net | Date: | Wed, 24 May 2006 21:14:17 +0000 |
| Subject: | note 66512 deleted from function.mysqli-multi-query by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-111964@lists.php.net to get a copy of this message | ||
Note Submitter: gperosio
Reason: in docs
----
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)
...