I am working in a GUI tool development using php. There are STORED PROCEDURES already present in the database. Those stored procedures cannot be changed. (other tool dependency).
My Question: There is a procedure which returns two tables when called in mysql directly. (maybe 2 select statement inside it).
How can I use 'mysqli -- php' to display the data from two tables returned?
NOTE : Both table returned has same columns(name,id,status) in it
Make use of mysqli::use_result
$mysqli = new mysqli("localhost", "root", "password", "db_name");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") ";
}
$query = "CALL sp_multiple results (?, ?)";
$stmt = $mysqli->prepare($query);
if (!$stmt) {
echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
$stmt->bind_param("ss", $param1, $param2);
$stmt->execute();
/* get first result set */
if ($result1 = $mysqli->use_result()) {
//fetch data
$result1->close();
}
/* get second result set */
if ($result2 = $mysqli->use_result()) {
//fetch data
$result2->close();
}
$mysqli->close();