Welcome Guest, Not a member yet? Register   Sign In
Passing Arguments from View to Controller?
#3

[eluser]jmadsen[/eluser]
beans,

My first thought is, you should make the join in the database query and return a single resultset. If you're not clear on how to do that, give us a shout and folks can explain how to set it up.

If you know about that, but have a reason for not joining the tables, then do all of your work in the controller. You can return either a resultset object or an array, so check how you want things set up. returning

Psuedo code to give you the idea:

Code:
if ($this->data->bookmarks = $this->Bookmarks->get_latest_bookmarks(4)){
    foreach ($this->data->bookmarks as &$bookmark){
        $bookmark->tags = $this->Bookmarks->get_bookmark_tags($bookmark->id);
    }
}
$this->load->view('welcome_message', $data);

That was banged out really quickly just to give you the idea. In your view, each bookmark will now have an array of tags linked to it. Try not to call model functions from a view; that goes against the idea of MVC


Messages In This Thread
Passing Arguments from View to Controller? - by El Forum - 06-10-2011, 06:41 PM
Passing Arguments from View to Controller? - by El Forum - 06-10-2011, 11:21 PM
Passing Arguments from View to Controller? - by El Forum - 06-10-2011, 11:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB