Home > Backend Development > PHP Tutorial > mysql stored procedure PHP calls MySQL stored procedure implementation code

mysql stored procedure PHP calls MySQL stored procedure implementation code

WBOY
Release: 2016-07-29 08:38:35
Original
1021 people have browsed it

MySQL seems to have only introduced stored procedures since 5.0. Anyway, I have never touched it when I was working on applications before. But now because it is mainly used for internal systems, many applications use stored procedures. Of course, the front desk sometimes needs to call MySQL stored procedures, PHP MySQL Lib doesn't seem to support it very well, but I searched for some information. Although there is not much, I still tried to use it. Now I will introduce the method so that friends who use it will not have a headache.
 lMySQL extension also supports stored procedures, but only supports stored procedures that do not return results. If the stored procedure has output, this call will throw an error. The specific error is forgotten. The calling method is very simple:
$rs = mysql_query("call func('str')", $conn);
If this returns a result, such as a string, an error will be reported. The solution I have found now is to use MySQLi Extension:
$rs = mysqli_query("call func('str')", $conn);
In this way, $rs can be used as an ordinary MySQL Result, which is very convenient.
When calling a stored procedure, you may also encounter a problem, that is, multiple stored procedures may be called sequentially, which will also report an error. The solution is to manually close the MySQL link after calling a stored procedure and completing the processing. Then connect again, call another stored procedure and process again. Reconnect as many times as you need to call the stored procedure.
Since I don’t know much about MySQL extensions, the above is purely a summary of experience. If there is any expert who knows the ins and outs, please give me some advice.

The above introduces the implementation code of mysql stored procedure PHP calling MySQL stored procedure, including the content of mysql stored procedure. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template