Ejemplo n.º 1
0
 public function csv()
 {
     if (!Loader::helper('validation/token')->validate('csv')) {
         $this->redirect('/dashboard/system/optimization/query_log');
     } else {
         $l = new LogList();
         $entries = $l->get(0);
         $fileName = "Database Query Log Results";
         header("Content-Type: text/csv");
         header("Cache-control: private");
         header("Pragma: public");
         $date = date('Ymd');
         header("Content-Disposition: attachment; filename=" . $fileName . "_form_data_{$date}.csv");
         $fp = fopen('php://output', 'w');
         // write the columns
         $row = array(t('Times Run'), t('Query'));
         fputcsv($fp, $row);
         foreach ($entries as $ent) {
             fputcsv($fp, array($ent['queryTotal'], $ent['query']));
         }
         fclose($fp);
         die;
     }
 }