Data Export (CSV)
How to export data from a table into a CSV file ?
Each collector can call the method downloadCSVBySQL which allows you to export all or part of the data from a table to a CSV file.
function downloadCSVBySQL($sql, $forExcel = false, $firstLine = array(), $addActionColumn = false) { }
Settings
- $sql : an SQL query.
- $forExcel : passed as true, this is sort of manage a good display if one wants to open the CSV file in Excel.
- $firstLine : a table with values that correspond to the labels that appear in column header in Excel.
- $addActionColumn : past to true, this parameter has the effect of adding an empty column "Action" which will be a role for data import.
Example
The following example allows you to retrieve a file .csv is thus presented in Excel.
$this->collector['example']->downloadCSVBySQL('SELECT id_example, lib, n_order FROM gen_example', $forExcel = true, array('ID', 'Title', 'Order'), $addActionColumn = false);
