MySQL seems to have introduced the stored procedure since MySQL 5.0, but it has never been touched before. However, because it is mainly used as an internal system, many applications use the stored procedure, of course, the front-end sometimes needs to call the MySQL stored procedure. PHP MySQLLib does not seem to support
MySQL seems to have introduced the stored procedure since MySQL 5.0, but it has never been touched before. However, because it is mainly used as an internal system, many applications use the stored procedure, of course, the front-end sometimes needs to call the MySQL stored procedure. the MySQL Lib in PHP does not seem to support very well, but I have searched some materials. although there are not many materials, I still tried to use them, now let's introduce the method so that you don't have to worry about it.
The lMySQL extension also supports stored procedures, but only supports stored procedures with no returned results. if the stored procedure has output, an error will be thrown during this call, and the specific error is forgotten. The call method is simple:
$ Rs = mysql_query ("call func ('str')", $ conn ); |
If a returned result is returned, for example, a string, an error is returned. the solution I have found is to use the MySQLi extension:
$ Rs = mysqli_query ("call func ('str')", $ conn ); |
In this way, $ rs is used as a normal MySQL Result, which is very convenient.
When calling a stored procedure, you may encounter another problem, that is, you may call multiple stored procedures in sequence, which also reports an error, the solution is to manually close the MySQL link after a stored procedure is called and processed, connect again, and call another stored procedure for further processing. how many stored procedures need to be called, the number of reconnections.
Because I am not very familiar with MySQL extensions, the above is a summary of experience.