Here is the code I use ... you can customize the columns you need in the export ...
Note. This CSV is sent directly to php://output
, which is written directly to the output buffer. This means that you do not save any CSV files on the server , and it can handle a much larger file size , which creates a giant array, and then tries to skip it.
header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=\"Jobs_".date('Mjy', $from)."-".date('Mjy', $to).".csv\""); header("Pragma: no-cache"); header("Expires: 0"); $handle = fopen('php://output', 'w'); fputcsv($handle, array( 'JobId', 'Template', 'Customer', 'Status', 'Error', 'PDF', 'Run Time', 'Wait Time', 'Server' )); foreach ($jobs as $jobData) { fputcsv($handle, array( $job->getId(), $job->getTemplate(), $jobData['customers_firstname'].' '.$jobData['customers_lastname'], $status, $error, $jobData['products_pdfupload'], $job->getRunTime(), $job->getWaitTime(), $jobData['server'] )); } fclose($handle); exit;
This should give you a good idea of ββhow CSV export works. I do not use the CodeIgniter File Upload Assistant, so I cannot help you on this front.
source share