0

I'm writing a MVC application in PHP from the scratch for an assignment. Where does the associated / related models are normally loaded.

I wrote the front controller, models and views and they are working. Now I need to load the associated models. I have defined the associations in the model. Now I need to place my associated model loading code somewhere in my application.

Any help appreciated.

Kasun Rajapaksha
  • 536
  • 1
  • 5
  • 22

1 Answers1

0

Where models are loaded depends on the complexity of your application/storage

  1. In a simple MVC framework you can load the model with info from a storage source from the controller yourself
  2. In a more advanced framework you can use a Service Layer to keep your code DRY and make it easier for yourself
  3. In all the big frameworks you most of the time have some sort of abstraction layer between the storage and your service layer
  • Thanks, Based on your answer, I checked the cakePHP and found that, it has a abstraction layer which handles all these complex things. Thanks for turning the lights on. – Kasun Rajapaksha Apr 08 '14 at 10:52
  • @KasunRajapaksha you really should **not** use CakePHP as example for proper application/framework design. – tereško Apr 12 '14 at 18:21
  • Really, why? I found that it's structure differs to the MVC definition. Is there any other serious issues. If so what framework you suggest? – Kasun Rajapaksha Apr 16 '14 at 07:07