[eluser]searain[/eluser]
I have an page to display event detail.
Event Title
Event Time
Event Description
No problem.
I have event_model.php to do the database query and return results to the event_view.php page to display.
But now,
The event could have sub events (identified by parent_id). So event detail could be
Event Title
Event Time
Event Description
Sub Event Title
Sub Event Time
Sub Event Description
Sub Event Title
Sub Event Time
Sub Event Description
Sub Event Title
Sub Event Time
Sub Event Description
So an easy solution is in the view page like above, query the sub event id one by one, and display them after query the data (in view page).
A MVC solution is still in event model page, query all the sub events. Return the sub events results with the parent event detail to the view page. This is doable. But in theory, if we have more layers of sub events such as
Event Title
Event Time
Event Description
Sub Event Title
Sub Event Time
Sub Event Description
SubSub Event Title
SubSub Event Time
SubSub Event Description
SubSubSub Event Title
SubSubSub Event Time
SubSubSub Event Description
Then doing all these layers sub..sub events query and return all results to the root event view page will be complicated.
But if we just query the sub events in the view page, in that layer, pick up the sub event id, do the query, return results and display, and then in the next layer, pick up the sub event id and do the query ... (all these subquery happens in view page) that will be easier.
So then should I stick with the rule that all database query in model, view only for view. or sometimes do query data in view page?
Is there a better solution that I can still do strict MVC but keep it simple?
Thanks!