I am attempting to output a CSV from a query result. dbutil->csv_from_result() should work, but it only returns the column headers. No data is included.
I tracked it down to system/database/DB_utility.php which uses unbuffered_row().
Any calls to unbuffered_row() return `NULL`. If I change it to row(), I get a result. It makes no difference if I use unbuffered_row('array') or unbuffered_row('object')`. In fact, row('array') doesn't seem to work either.
Why does row() work but unbuffered_row() does not?
What am I missing?
EDIT: Okay, the problem seems to be that I called $query->result() prior to calling dbutil->csv_from_result().
New question: Is there a way to display the results of a query and simultaneously save the CSV of results without having to run the query twice?
I tracked it down to system/database/DB_utility.php which uses unbuffered_row().
Any calls to unbuffered_row() return `NULL`. If I change it to row(), I get a result. It makes no difference if I use unbuffered_row('array') or unbuffered_row('object')`. In fact, row('array') doesn't seem to work either.
Why does row() work but unbuffered_row() does not?
What am I missing?
EDIT: Okay, the problem seems to be that I called $query->result() prior to calling dbutil->csv_from_result().
New question: Is there a way to display the results of a query and simultaneously save the CSV of results without having to run the query twice?