Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Call to undefined method CI
#5

(09-15-2017, 06:39 AM)stckitbr Wrote: Hi guys, I'm having this problem when trying to generate an excel file with the data that is displayed on the screen. Clicking will show this error.

Fatal error: Call to undefined method CI_DB_mysql_utility::csv_from_array() in C:\wamp64\www\application\controllers\fluxo_caixa.php on line 259

help?  Huh

Try this 
Code:
$query_str="whatever your sql query maybe";
$query=$this->db->query($query_str);
$result_array = $query->result_array();
$fp = fopen('file.csv', 'w');

foreach ($result_array as $rs) {
   fputcsv($fp, $rs);
}

fclose($fp);

The snippet will get your result array and write to csv file.  Just make sure you set correct permission on 'file.csv'.  Also on query_str
if you need to pass on param within the sql statement then you need to use $this->db->escape($param), e.t.c

You can use active record method as per doc it will auto escape the param for you , how you want to write it is up to you

Regards
Reply


Messages In This Thread
RE: Fatal error: Call to undefined method CI - by ciadvantage - 09-16-2017, 08:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB