MySQL seems to be starting from 5.0 to introduce stored procedures, anyway used to do the application has never touched, but now because the main internal system, so many applications have used the stored procedures, of course, the front desk sometimes need to call the MySQL stored procedures, php MySQL Lib seems to support is not very good, But I searched for some information, although not many, but still try to use, now introduce methods, so that the use of friends no longer headaches.
The lmysql extension also supports stored procedures, but it only supports stored procedures with no return results, and if the stored procedure has output, the call throws an error and the specific error is forgotten. The invocation method is simple:
$rs = mysql_query ("Call func (' str ')", $conn);
If there is a return result, such as a return string, it will be an error, and the workaround I find now is to use the mysqli extension:
$rs = Mysqli_query ("Call func (' str ')", $conn);
This $rs as a normal MySQL result to use, very convenient.
When calling a stored procedure, you may also encounter a problem, that is, you may call multiple stored procedures sequentially, so that the same error, the solution is to call a stored procedure and processing is completed, manually close the MySQL link, and then connect again, and then call another stored procedure to process, How many stored procedures need to be called, and how many times are reconnected.
Because I do not know much about MySQL extension, the above is purely empirical summary, if there is a master know the ins and outs, welcome guidance.
The above describes the MySQL stored procedure php call MySQL stored procedure implementation code, including the contents of the MySQL stored procedures, I hope to be interested in PHP tutorial friends helpful.