Simply put, when im exporting query results to a csv, it goes smooth as silk till the query results reach about 20k-25k records.
When I hit that mark, I get a blank white screen and the file thats created only has the header row and nothing else. I pull the query back a little and it goes off fine, building the csv file with all data.
I've tried various records, queries and tables to make sure it wasn't the data so I'm at a loss. I can query fine and paginate easily over 1million records but the export still fails.
$file_name = "new_file";
//Set field column names
$fields[] = 'Submit Date';
$fields[] = 'Submit Time';
$fields[] = 'Client STN';
$fields[] = 'Incident Type';
$fields[] = 'Level 1';
$fields[] = 'Level 2';
$fields[] = 'Level 3';
$fields[] = 'Employee ID';
//Create file
$fp = fopen('/var/www/html/data_exports/'.$file_name.'.csv', 'a');
if ($fp && $result)
{
fputcsv($fp, $fields);
foreach ($result->result_array() as $row)
{
$values = array();
$values[] = $row['submit_date'];
$values[] = date("H:i:s", $row['submit_time']);
$values[] = $row['stn'];
$values[] = $row['menu_text'];
$values[] = $row['lvl1_menu_item'];
$values[] = $row['lvl2_menu_item'];
$values[] = $row['lvl3_menu_item'];
$values[] = $row['employee_id'];
fputcsv($fp, $values);
}
}
redirect('admin/data_export_files');