How PHP gets the stored procedure where MySQL has a return value with a query
Stored Procedures
CREATE PROCEDURE A (out B int)
Begin
Select 10;
Set b=3;
End
Php
$tsql. = "Call a (@b);";
$tsql. = "select @b;";
if ($mysqli->multi_query ($tsql)) {
if ($result = $mysqli->store_result ()) {
while ($row = $result->fetch_array ()) {
Array_push ($data [' table '], $row);
}
}
if ($mysqli->more_results ()) {//Determine if there is a result set
if ($mysqli->next_result ()) {
if ($result = $mysqli->store_result ()) {
if ($row = $result->fetch_row ()) {
for ($i = 0, $count = count ($row); $i < $count; $i + +) {
$data [' Output '] [$i] = $row [$i];
}
}
}
}
}
} else {
echo "ERROR:", $mysqli->errno, "---", $mysqli->error;
}
Print_r ($data [' output ']);
There is no way to get the return value if it is directly select B without the return value, or the stored procedure does not query or
You can't get the return value if you have two of them.
How does this work?
------Solution--------------------
PHP code
!--? PHP 2 define (' Client_multi_results ', 131072) ; 3 4 $link = mysql_connect ("127.0.0.1", "Root", "" ", 1,client_multi_results) or Die (" Could Not Connect: ". Mysql_error ()) ; 5 mysql_select_db ("vs") or Die ("Could not select Database"); 6?--> 7 8!--? php 9 $result = mysql_query ("Call get_news_from_class_id (2)") or Die ("Query failed:". Mysql_er Ror ()), ten while ($row = Mysql_fetch_array ($result, Mysql_assoc)) {$line = '
'. $ro w["title"]. ' ('. $row ["Page_time"]. ') '. '; echo $line ("\ n"),}18 mysql_free_result ($result); ;!--? php22 mysql_close ($link);?-->