php-developer
php-developer

Reputation: 21

PHP export to CSV dies after 10000 records

I want to export my result set, of about 26000 records, into csv.

It's not working when it goes past the 10000 range.

Even after I have changed the max_execution_time to 60 in php.ini.

My code looks like this:

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print "$header\n$output";

Can anyone give me a heads up to where I'm going wrong?

Upvotes: 2

Views: 1916

Answers (1)

Denis Arh
Denis Arh

Reputation: 21

Why storing everything into $output? Output each line as you read it from the database, no need to use up memory to store everything just for output.

And avoid fetchAll and similar methods... output each row...

Upvotes: 1

Related Questions