The example in this article describes how to call and execute the mysql stored procedure in PHP and then return the value returned by the stored procedure. I would like to share it with you for your reference. The specific analysis is as follows:
Methods that call stored procedures.
a. If the stored procedure has IN/INOUT parameters, declare a variable and input the parameters to the stored procedure. The variable is a pair, a PHP variable, or not. However, if there is no PHP variable, there is no way to dynamically input a Mysql variable.
b. If the stored procedure has an OUT variable, declare a Mysql variable. The declaration of the mysql variable is special. The mysql server must know the existence of this variable. In fact, it means executing a mysql statement and entering set @mysqlvar=$phpvar;
c. Use mysql_query()/mysql_db_query() to execute the mysql variable declaration statement.
The code is as follows:
In this way, there is a variable in the mysql server, @mysqlar. If it is an IN parameter, then its value can be passed in from phpar.
For example, using the mysqli function instance, we can first create a stored procedure in mysql, the code is as follows:
Error:%d (%s) %sn", mysqli_errno($dbh),
mysqli_sqlstate($dbh), mysqli_error($dbh));
}
Print (" ");
$dbh->close();
}
?>
The core code is as follows:
This employee_list is our mysql stored procedure.
I hope this article will be helpful to everyone’s PHP programming design.