|
fputcsv slow
Hi All,
Good day.
I created a script that put all data from mysql database to csv file. Im using fputcsv. It's working fine but when the data is large like 15000 and up the writing is verly slow. it took like 1-2 days to write it all in the csv.
How would I do it fastly?
This is my sample code and the it returns like 15000 records and more..
$query = select * from table;
$row = mysql_query($query);
foreach ($rows as $row)
$list = array($row['a'],$row['b'],$row['c'],$row['d']);
$fp = fopen('file.csv', 'w');
foreach ($list as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);
I tried to execute the query on the database and it only took less than a minute.
hope someone could help
|