How does PHP control Mysql execution time?

Source: Internet
Author: User
In the php background, we often do some mysql persistent queries. for example, if the execution time of an SQL statement is 60 seconds, can php disable mysql query if the execution time of msyql exceeds 30 seconds. in the php background, we often do some mysql persistent queries. if the execution time of an SQL statement is 60 seconds, can php set it? If the execution time of msyql exceeds 30 secondsTo terminate the mysql query.

Reply content:

In the php background, we often do some mysql persistent queries. If the execution time of an SQL statement is 60 seconds, can php setIf the execution time of msyql exceeds 30 secondsTo terminate the mysql query.

Php. ini has a setting to set the mysql connection timeout in a request.

PhpIni_set ('mysql. connect_timeout ', 30 );

However, this is the timeout time for all the mysql requests in your script. Your problem is that you want to set the timeout time for an SQL statement. This does not exist and does not seem to work.

UseMysqliYou can also set
$ Mysqli = mysqli_init ();
$ Mysqli-> options (MYSQL_OPT_READ_TIMEOUT, 30 );

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.