How does PHP ensure that the process of loop query and local data update executed through the interface is completed correctly? -Php Tutorial

Source: Internet
Author: User
Currently, a function is being developed. This function will be triggered when I click the "save" button on the page for setting parameters. Considering this function, different ID parameters need to be sent cyclically to request data from the interface, and then each loop updates the phase of the local database according to the obtained data... currently, a function is being developed. This function will be triggered when I click the "save" button on the page for setting parameters.

Considering this function, different ID parameters need to be sent cyclically to request data from the interface, then, each loop updates the related fields of the local database based on the obtained data (this loop request may have a large number of times and may be thousands of times in the future )...... How can I ensure that this loop operation will be completed due to network latency, blocking, and other issues?

Reply content:

Currently, a function is being developed. This function will be triggered when I click the "save" button on the page for setting parameters.

Considering this function, different ID parameters need to be sent cyclically to request data from the interface, then, each loop updates the related fields of the local database based on the obtained data (this loop request may have a large number of times and may be thousands of times in the future )...... How can I ensure that this loop operation will be completed due to network latency, blocking, and other issues?

Database transactions and multiple SQL statements in a transaction can be rolled back if one fails.

Since you know that you want to request multiple interfaces, we recommend that you change the request to one time. we recommend that you use cache for a lot of requested data and use a queue for asynchronous database transaction operations.

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.