note 119658 added to mysqli.multi-query
| From: | StjepanBrbot | Date: | Wed, 27 Jul 2016 11:12:46 +0000 |
| Subject: | note 119658 added to mysqli.multi-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206115@lists.php.net to get a copy of this message | ||
This example shows how to read data from multiple stored procedures. Here I have two stored
procedures proc1() and proc2() and retrieve their data into 2D array:
<?php
$db=new mysqli(...);
$sql="CALL proc1(...); CALL proc2(...);";
$procs=[]; //outer array for resultsets (tables)
$cols=[]; //inner array for columns (fields)
if($db->multi_query($sql))
{
do
{
$db->next_result();
if($rst=$db->use_result())
{
while($row=$rst->fetch_row())
{
$cols[]=$row[0]; //fetch 1st column value
$cols[]=$row[1]; //fetch 2nd column value
}
$procs[]=$cols; //add cols to procedures array
}
}
while($this->db->more_results());
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 78.2.224.137
----
Manual Page -- http://php.net/manual/en/mysqli.multi-query.php
Edit -- https://master.php.net/note/edit/119658
Del: integrated -- https://master.php.net/note/delete/119658/integrated
Del: useless -- https://master.php.net/note/delete/119658/useless
Del: bad code -- https://master.php.net/note/delete/119658/bad+code
Del: spam -- https://master.php.net/note/delete/119658/spam
Del: non-english -- https://master.php.net/note/delete/119658/non-english
Del: in docs -- https://master.php.net/note/delete/119658/in+docs
Del: other reasons-- https://master.php.net/note/delete/119658
Reject -- https://master.php.net/note/reject/119658
Search -- https://master.php.net/manage/user-notes.php