Question

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.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top