PHP Big Data export CSV problem

Source: Internet
Author: User
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

  • Related Article

    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.