When I tried to create a CSV file using dbutil->csv_from_result() CI3 gave me just a header record missing whole actual data rows.
I found something after I played around with system/database/DB_utility.php.
The original code is (CI3.1.7 is the same) like this;
PHP Code:
// Next blast through the result array and build out the rows
while ($row = $query->unbuffered_row('array'))
{
$line = array();
foreach ($row as $item)
{
$line[] = $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure;
}
$out .= implode($delim, $line).$newline;
}
In my environment (CI3 and PostgreSQL 10), there was no unbuffered_row in the query object, so the try misses.
I remember CI2's dbutil->csv_from_result() worked fine with PostgreSQL 9.2 and the code in the both programs look the same...
Then I gave a modification to the original code as follows and it works fine for me.
PHP Code:
//while ($row = $query->unbuffered_row('array')) // Original : while iteration doesn't work with object
foreach ($query->result_array() as $row)
{
$line = array();
foreach ($row as $item)
{
$line[] = $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure;
}
$out .= implode($delim, $line).$newline;
}
I'm not exactly sure if it works for everyone, but I believe it will help someone who have the same issue as I had.