model/view/controller logic - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: model/view/controller logic (/showthread.php?tid=55016) |
model/view/controller logic - El Forum - 10-05-2012 [eluser]marc0[/eluser] Hey, just getting into codeIgniter, what a great platform ! Here's the situation : I have a controller that gets real-estate listings (properties) from a listings table Now I have another table, containing open houses infos. So in my properties controller: -- Code: $data['proprietes'] = $this->model_proprietes->get_proprietes($config['per_page'], $offset); Now i need to add openhouse infos to the listings. The only way I can think of getting every open houses would be like this inside my properties view : Code: foreach ($properties as $p) { Thit just looks like horrible MVC programming to me... any suggestions ?! model/view/controller logic - El Forum - 10-05-2012 [eluser]marc0[/eluser] Found this ! http://stackoverflow.com/questions/3494463/retrieve-second-table-as-subarray-in-codeigniter-query model/view/controller logic - El Forum - 10-06-2012 [eluser]marc0[/eluser] Here's what I was looking for, all done inside the controller. Code: $properties = $this->db->get('properties')->result(); model/view/controller logic - El Forum - 10-06-2012 [eluser]jmadsen[/eluser] Use a database join. If you have formatting issues, try working with underscore.php or similar. Here's a quick tut I wrote to show how easy it is & how much performance you can save: http://www.codebyjeff.com/blog/2012/08/no-more-machine-gunning-use-underscore-php (Today seems to be "Plug my Blog Day" :-) ) |