Welcome Guest, Not a member yet? Register   Sign In
How do I re-use query results?
#8

[eluser]CJL01[/eluser]
[quote author="TheFuzzy0ne" date="1243206011"]What's wrong with copying the result array/object to a variable, and re-using that?

You are using the result array anonymously. Really, result_array/result are both single-use methods. If you want to re-use the result array, you'll need to store it somewhere.
[/quote]

Got it - the result_array is single use so I can't keep re-using it. All my library functions need is result_array() and field_data(), so I've stored these into variables and then pass them in as two separate arguments into each of my subsequent calls. This works perfectly, and allows me to re-use the data again and again.

Thanks very much TheFuzzyOne!!

Code:
$query = $this->new_model->daily_summary();
        $fields = $query->field_data();
        $results = $query->result_array();
        $query->free_result();
        
        $table = $this->datatable->generate($fields, $results);
        $data['output'] = '<h3>Trading Daily Summary</h3>'.$table;

        $graph = $this->graph->new_line_chart(1, 'N', $fields, $results);
        $data['output'] .= '<br />'.$graph;

        $graph = $this->graph->new_line_chart(4, 'N', $fields, $results);
        $data['output'] .= '<br /><br />'.$graph;


Messages In This Thread
How do I re-use query results? - by El Forum - 05-24-2009, 10:54 AM
How do I re-use query results? - by El Forum - 05-24-2009, 11:06 AM
How do I re-use query results? - by El Forum - 05-24-2009, 11:22 AM
How do I re-use query results? - by El Forum - 05-24-2009, 11:23 AM
How do I re-use query results? - by El Forum - 05-24-2009, 11:26 AM
How do I re-use query results? - by El Forum - 05-24-2009, 11:28 AM
How do I re-use query results? - by El Forum - 05-24-2009, 12:00 PM
How do I re-use query results? - by El Forum - 05-24-2009, 02:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB