MySQL stored procedure PHP calls the implementation code of the MySQL stored procedure

Source: Internet
Author: User
Tags php mysql
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.