I'm hoping there is a simple solution here:
My code is basically
....some code.... //populates a MySQL table
include 'run_this_page.php'; //uses data from table above and takes ten minutes to run
....lots more code.... ///also uses data from same table
As the include
takes ten minutes to excute, I'd like for it to be initiated and then move on immediately to the next step. Nothing in the include
is required for these next steps. I can think of several non-elegant (create a txt file which will trigger a scheduled task in Windows rather than using include etc) ways to achieve this, is there a more elegant method?
*Update*
I'm being attacked (politely) by many over the structure of my script. Let me explain a bit more what the purpose is:
1 - Raw data is gathered from a 3rd party API, filtered via the script and stored in the database. Because of limitations in this API, I have to restrict the requests to small chunks and this can easily take over 20 minutes. From this data I am looking for two distinct result sets. Each one of these sets are stored in its own table. This will soon grow to a dozen result sets in a dozen tables. (I could use only one table, but it makes no difference for our discussion).
2 - Now that I have the result sets, I have two distinct scripts that go out and gather data about each. Because the target 3rd party sites are completely different I wrote the scripts in their own files and simply want them to both run now. Each can take upwards of ten minutes.
I hope this explanation helps
Open a socket, write to it and close the socket. Be careful, your code will be executing asynchronously:
A simple method to load PHP asynchronously is to just use jQuery and AJAX.
OR ...
A more robust solution, if you want to load example.php on demand, would be to run a cron job programmatically when the user clicks a 'process data' button on that page.
Then you could use AJAX to ping the server every 60 seconds until the data is updated and pull it in using the same code from above.
OR ...
php execute a background process