PHP How to get MySQL has a return value there is a query stored procedure

Source: Internet
Author: User
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);?--> 
    
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.