PHP中的批处理

I have customer's list having more than 3000 records and I run a process for each customer at one click one by one.

I called CURL for call my script file and run this process in background. But after some time my script get failed due to script timeout error. I don't want to change php.ini parameters.

I want to handle it with the help of Batch processing. How can I do this with the help of CURL ? or any logic...

Thanks!!

-Pravin

set_time_limit

Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini.

Use

set_time_limit(0);

Add that to your script and it won't timeout.

You must implements an Ajax responser: I'll suggest you a way to do it

  1. Create a class to process your requests by small chunks (AjaxProcessor). There you must locate functions to update your db and to prepare advance reports to be sent to the client.
  2. Create a path related to your AjaxProcessor
  3. In your page locate a button to submit your first call, a hidden field to register the calling status, perhaps a div to show the advance.
  4. write a small Javascript to iterate calls to your batch path, While status stays flagged as not complete.
  5. use jQuery to send your requests.