U kunt model CSV()
. aanroepen van je controller als
$this->load->model('Users_model');
$this->Users_model->csv();
en in het model
function csv()
{
$this->load->dbutil();
$this->load->helper('file');
$this->load->helper('download');
$query = $this->db->query("SELECT * FROM Users");
$delimiter = ",";
$newline = "\r\n";
$data = $this->dbutil->csv_from_result($query, $delimiter, $newline);
force_download('CSV_Report.csv', $data);
}
Uw bestand wordt gedownload