Welcome Guest, Not a member yet? Register   Sign In
Improving performance of csv_from_result method
#5

[eluser]googlymoogly[/eluser]
audiopleb: it's identical to Ryno's without the hardcoded $delim and $enclosure.

Code:
if (! function_exists('csv_from_result'))
{
    function csv_from_result($query, $delim=",", $newline="\n", $enclosure='"')
    {
        if ( !is_object($query) || !method_exists($query, 'field_names')) {
            show_error('You must submit a valid result object');
        }    

        $out = '';
        
        // First generate the headings from the table column names
        $out = $enclosure . implode($enclosure . $delim . $enclosure, $query->list_fields()) . $enclosure . $newline;

        // Next blast through the result array and build out the rows
        foreach ($query->result_array() as $row) {
            $out .=  $enclosure . implode($enclosure . $delim . $enclosure, $row) . $enclosure . $newline;
        }
        return $out;
    }
}


Messages In This Thread
Improving performance of csv_from_result method - by El Forum - 07-31-2008, 08:17 PM
Improving performance of csv_from_result method - by El Forum - 09-10-2008, 04:36 AM
Improving performance of csv_from_result method - by El Forum - 09-10-2008, 06:10 AM
Improving performance of csv_from_result method - by El Forum - 09-10-2008, 04:39 PM
Improving performance of csv_from_result method - by El Forum - 09-11-2008, 09:12 AM
Improving performance of csv_from_result method - by El Forum - 09-11-2008, 09:15 AM
Improving performance of csv_from_result method - by El Forum - 09-11-2008, 10:29 AM
Improving performance of csv_from_result method - by El Forum - 09-11-2008, 03:26 PM
Improving performance of csv_from_result method - by El Forum - 02-07-2009, 05:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB