Requesting many different sections of database in one page - 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: Requesting many different sections of database in one page (/showthread.php?tid=39123) |
Requesting many different sections of database in one page - El Forum - 03-01-2011 [eluser]xerosis[/eluser] I have a website where in the body section of the homepage I need to retrieve: - News (from news table) - Top 10 users (from users table) - 5 latest games (from games table) - 5 latest videos (from videos table) - 5 latest slideshow (from slideshow table) I already have a model for each of these where I can add, update, retrieve, and delete them. What I want to know is on my Main Controller (which manages the homepage) must I: - Call each model - Use the GetUser, GetNews, GetGames, etc. functions to retrieve the data. - Save each as for example $data['user'], $data['news'], $data['game'] etc. - Send $data with view? Or should I create a specific model just for Homepage? Thanks. Requesting many different sections of database in one page - El Forum - 03-01-2011 [eluser]johnpeace[/eluser] [quote author="xerosis" date="1299027919"]I have a website where in the body section of the homepage I need to retrieve: - News (from news table) - Top 10 users (from users table) - 5 latest games (from games table) - 5 latest videos (from videos table) - 5 latest slideshow (from slideshow table) I already have a model for each of these where I can add, update, retrieve, and delete them. What I want to know is on my Main Controller (which manages the homepage) must I: - Call each model - Use the GetUser, GetNews, GetGames, etc. functions to retrieve the data. - Save each as for example $data['user'], $data['news'], $data['game'] etc. - Send $data with view? Or should I create a specific model just for Homepage? Thanks.[/quote] I'd take the first approach and call each model for the data I needed from that model. Why write a new model when you already have code that gets the data your controller needs? Expecially since it'd be largely redundant code... Requesting many different sections of database in one page - El Forum - 03-01-2011 [eluser]xerosis[/eluser] I agree. The only reason I was asking was because each of these models have so many different functions which I do not even use, I thought it may sacrifice performance. |