Php calls the mysql Stored Procedure

Source: Internet
Author: User

I have previously reproduced an article titled php calling mysql stored procedure. After testing, I found that the methods in this article seem to be unavailable!

The PROCEDURE p can't return a result set in the given context error occurs when you call a stored PROCEDURE with a select statement. After google for half a day, I found some comments on the mysql official website. The db_mysql module does not support stored procedure calling. The solution is to use db_mysqli. After testing, you can.

It is easy to use and has nothing to say. copy a piece of code from the Internet:

<? Php
/* Connect to a MySQL server */
$ Link = mysqli_connect (
'Localhost',/* The host to connect */
'Root',/* The user to connect */
'Root',/* The password to use */
'Db _ name');/* The default database to query */
If (! $ Link ){
Printf ("Can't connect to MySQL Server. Errorcode: % s \ n", mysqli_connect_error ());
Exit;
}
/* Send a query to the server */
If ($ result = mysqli_query ($ link, "call se_proc ('crm ')")){
/* Fetch the results of the query */
While ($ row = mysqli_fetch_array ($ result )){
Echo ($ row [0]. "--------- SR.". $ row [1]."
");
}
/* Destroy the result set and free the memory used for it */
Mysqli_free_result ($ result );
}
/* Close the connection */
Mysqli_close ($ link );
?>

What's depressing is that the efficiency of the stored procedure after a long time is not as high as before --

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.