Home > Article > Backend Development > Collection of methods for calling MySQL stored procedures in php_PHP tutorial
This article is a collection and summary of the methods of calling MySQL stored procedures in PHP. Friends in need can refer to it.
Type 1: Calling a method with input and output type parameters
Type 2: Calling a method with multiple output types and multiple input type parameters
Type 3: Calling a method that returns a result set
Type 4: Calling a method that returns multiple result sets (currently only possible through mysqli~~)
//PHP
$rows = array ();
$db = new mysqli($server,$user,$psd,$dbname);
if (mysqli_connect_errno()){
$this->message('Can not connect to MySQL server');
}
$db->query("SET NAMES UTF8");
$db->query("SET @Message");
if($db->real_query("call P__Test_GetData2(@Message)")){
do{
If($result = $db->store_result()){
while ($row = $result->fetch_assoc()){
array_push($rows, $row);
$result->close();
}while($db->next_result());
}
$db->close();
print_r($rows);
//Procedure
…
select * from T1 where ……
select * from T2 where ……
……
http://www.bkjia.com/PHPjc/372461.html