PHP 8.5.0 Beta 1 available for testing

Voting

: max(four, two)?
(Example: nine)

The Note You're Voting On

Stjepan Brbot
9 years ago
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());
}

?>

<< Back to user notes page

To Top