I am now using PHP to export the CSV implementation process is a file, then the batch query data and then the Foreach loop in a write to the file, after the completion of the download method to download the file, I now the problem if more data, the PHP program is finished, to see the file is still written, Can not execute the download method, so the file will not download, what is the solution to this problem?
Reply content:
I am now using PHP to export the CSV implementation process is a file, then the batch query data and then the Foreach loop in a write to the file, after the completion of the download method to download the file, I now the problem if more data, the PHP program is finished, to see the file is still written, Can not execute the download method, so the file will not download, what is the solution to this problem?
This amount of data, a single PHP request will typically time out.
PHP files are recommended to process only 10 data per request, append to the CSV file, a single request to return quickly.
Then write a JS program, the Ajax loop calls this PHP file, until the data are processed, triggering the Web download action. This also has the advantage that the front-end Web page can display processing progress in real time.
Because the CSV nature is plain text, you can cooperate with JS and PHP,JS to initiate multiple requests in batches of past strings, and finally let JS merge the generated files (linked in the way of data:)
File not fully generated, button is disable state