• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Requesting many different sections of database in one page

#1
[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.

#2
[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...

#3
[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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.