first commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
function export($r, $name = 'download') {
|
||||
set_time_limit(0);
|
||||
$filename = $name . "-" . date("Y-m-d-H-i-s") . ".csv";
|
||||
header('Content-Type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment;filename="' . $filename . '"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
$i = 0;
|
||||
if (ob_get_contents()) ob_end_clean();
|
||||
$out = fopen('php://output', 'w');
|
||||
while ($row = $r->unbuffered_row()) {
|
||||
$f = (array) $row;
|
||||
if ($i == 0) {
|
||||
fputcsv($out, array_keys($f), ",");
|
||||
}
|
||||
fputcsv($out, array_values($f), ",");
|
||||
$i++;
|
||||
}
|
||||
fclose($out);
|
||||
}
|
||||
Reference in New Issue
Block a user