outputCSV() public static method

Output a CSV-file as a download
public static outputCSV ( string $filename, array $array, array $columns = null, array $excludeColumns = null )
$filename string The name of the file.
$array array The array to convert.
$columns array The column names you want to use.
$excludeColumns array The columns you want to exclude.
Ejemplo n.º 1
0
 /**
  * Execute the action.
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendFormBuilderModel::exists($this->id)) {
         parent::execute();
         $this->setFilter();
         $this->setItems();
         BackendCSV::outputCSV(date('Ymd_His') . '.csv', $this->rows, $this->columnHeaders);
     } else {
         // no item found, redirect to index, because somebody is f*****g with our url
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }