Skip to content

Instantly share code, notes, and snippets.

@kferran
Created January 4, 2013 21:44
Show Gist options
  • Save kferran/4457163 to your computer and use it in GitHub Desktop.
Save kferran/4457163 to your computer and use it in GitHub Desktop.
$app->match('/export', function() use($app){
$sql = 'SELECT * FROM partial_customers';
$records = $app['db']->fetchAll($sql);
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=partial_customers.csv");
header("Pragma: no-cache");
header("Expires: 0");
$output = fopen("php://output", "w");
foreach ($records as $row)
fputcsv($output, $row, ',');
fclose($output);
exit();
})->bind('dump');
@tmosest
Copy link

tmosest commented Feb 18, 2016

Thanks man this was super helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment