Posted on 2018-10-29 05:26:08
function ExportCSV() { $this->load->dbutil(); $this->load->helper('file'); $this->load->helper('download'); $delimiter = ","; $newline = "\r\n"; $filename = "filename_you_wish.csv"; $query = "SELECT * FROM table_name WHERE 1"; $result = $this->db->query($query); $data = $this->dbutil->csv_from_result($result, $delimiter, $newline); force_download($filename, $data); }