Du kan anropa modellen CSV()
från din handkontroll som
$this->load->model('Users_model');
$this->Users_model->csv();
och i modellen
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);
}
Din fil börjar laddas ner