[eluser]woracal[/eluser]
Hi all,
I need to use multiple query results in a single view. I'm quite new to CI. Appreciate some help/pointers to sample code.
thanks!
[eluser]woracal[/eluser]
thanks a ton!
[eluser]obiron2[/eluser]
Same principle, but may make your code easier to read (personal preferance really)
$pass_to_view['result']= $this->db->get('my_table')->result();
...
$pass_to_view['other_result'] = $this->db->get('my_other_table')->result();
...
$this->load->view('my_view',$pass_to_view);
$pass_to_view is then a key=>value array and when it gets to the view, each key will automatically be available as its own variable / array and the view code will be exactly the same.
[eluser]Jamongkad[/eluser]
Nice how would it be possible if you want to display the query from MYSQL in reverse chronological order. Let's say you make a blogging application and you want to have the newest posts displayed at the top of the page first.
[eluser]obiron2[/eluser]
The problem with defining sorting and grouping criteria within the SQL is that you now need two functions (or a complicated function)if you need to sort the data in different ways.
If you group and sort raw data sets outside of the SQL then you keep the models simple (but sacrifice speed)
[eluser]Rufus09[/eluser]
Thanks allot for this information. I am coming back to CI after a couple years in hiatus, and have forgotten a lot of what I knew, not that I was exactly a pro to begin with. I am finding a lot of great threads here which are really helping me get back up to speed. I am very grateful for this forum.