Note that there are some explanatory texts on larger screens.

plurals
  1. POphp script longer than max execution time (progress bar)
    text
    copied!<p>i currently work on a small project, where some data is gathered from the web and the system creates some relations between these. Of course it was not perfect from the beginning, so i needed to make a script which updates all the connections and relations with the updated scripts i made.</p> <p>Basically the script works, but as there shall be a nice looking backend afterwards, its not really what i want.</p> <p>The script needs around 10 minutes and because i didnt just want to set up the max_execution_time from php i thought of another method. Instead of loading 1000 sql entries at once i stripped it down to 200 at one time and just repeat it with the next 200 when the first round finished. Therefore i used php http_request. I just show you a stripped down version of the script:</p> <pre><code>require_once 'HTTP/Request.php'; $max = $db-&gt;query("SELECT COUNT(id) as max FROM db_table"); $lower = $_POST['lower'] ? $_POST['lower'] : 0; $plus = 250; $entries = $db-&gt;query("SELECT * FROM db_table LIMIT {$lower},{$plus}"); foreach($entries as $entry){ DO SOME STUFF TO UPDATE THE RELATIONS BETWEEN THE DATA } $lower = $lower + $plus; if($lower &lt;= $max) { $request = new HTTP_Request("path to the script"); $request-&gt;setMethod(HTTP_REQUEST_METHOD_POST); $request-&gt;addPostData("lower", $lower); $result = $request-&gt;sendRequest(); } </code></pre> <p>This is it. As i said it works, because it's a new request so that it's not affected by the max_execution_time. But the browser is just loading and loading and loading and after a while it finishes. But of course i cannot show any refreshed data for something like a progress bar.</p> <p>I saw many entries using php flush(), but that didnt work for me because of the (i guess) stupid way i used to solve my problem. How would you do this if you need to install something on a webspace and you dont have the possbility to change the max execution time or install http_request?</p> <p>As i said it should look like a progress bar later on. I guess i have to use ajax, and simply push the round the script is at every round and update the progress bar via javascript.</p> <p>Can you help me?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload