![]() |
csv_from_result only returning column labels - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: csv_from_result only returning column labels (/showthread.php?tid=67983) |
csv_from_result only returning column labels - CraigAMcLeod - 05-04-2017 I'm looking to use CSV from result to produce a CSV file from a query; my code is like this; PHP Code: $delimiter = ","; and only returns the following Code: "learnerID","NameFirst","NameLast","MobileNumber" Code: array (size=3) RE: csv_from_result only returning column labels - Rufnex - 05-05-2017 Maybe your sql statement is wrong? You should have somethink like that: Code: $query = $this->db->query("SELECT learnerID, NameFirst, NameLast, MobileNumber FROM your_table"); RE: csv_from_result only returning column labels - CraigAMcLeod - 05-05-2017 (05-05-2017, 01:47 AM)Rufnex Wrote: Maybe your sql statement is wrong? You should have somethink like that: It's like this: PHP Code: ->select('learnerID , NameFirst, NameLast, MobileNumber') Edit: shot in the dark, here's my csv_from_result code. PHP Code: $delimiter = ","; RE: csv_from_result only returning column labels - CraigAMcLeod - 05-07-2017 OK I found my problem, essiently using $query = $this->db->get(); basicly futzes with $query's object and makes it useless for csv_from_result. OK, that found out I now have an issue as I do not know how to get the query builder to generate an object and not a Missing argument 1 for CI_DB_driver::list_fields() result. I tried using "get_compiled_select" but that doesn't work. I need the query builder to work with CSV_from_result. |