A simple way to take steps to execute a PHP run time-out

Source: Internet
Author: User
  1. !--? php $stid = isset ($_get[' STI d '])? $_get[' Stid ']:0;

  2. $endid = $stid +;
  3. $maxid = 10000;

  4. Function dosomething () {

  5. //More Time-more actions
  6. ...
  7. }
  8. $sql _string= "select * from ' table ' where id> ' $stid ' and id<= ' $endid ' ORDER by id ';
  9. $datas = getdata_bysql ($sql _string);
  10. foreach ($datas as $data) {
  11. //Processing data
  12. ...
  13. echo $id. "Processing is complete.
    ";
  14. if ($id >= $maxid) {exit;}
  15. }
  16. if ($stid <= $maxid) {
  17. $stid = $stid +;
  18. $url = "action.php?stid= $stid";
  19. echo $url;
  20. Echo ';
  21. }
  22. ?
copy code

Where do Something () is a time-consuming operation. Here we can reduce the run time by restricting the ID range, and run the next step automatically after running through the JavaScript jump. In this way, each batch of data will be able to know the results, if the interruption also know that the problem is there.

  • 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.