MySQL seems to have only introduced stored procedures since 5.0. Anyway, I have never touched them when I was doing applications before. But now because it is mainly used for internal systems, many applications use stored procedures. Of course, the front desk sometimes needs them. To call MySQL stored procedures, PHP's MySQL Lib doesn't seem to support it very well. However, 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.
MySQL 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 the MySQLi extension:
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 MySQL after calling a stored procedure and completing the processing. Link, then connect again, then call another stored procedure and process it. Reconnect as many times as you need to call the stored procedure.