0
I am studying MVC and came across the following situation:
I have a View that needs to receive data from two different Models, so in the controller of this View I have the function below:
public function teste($id) {
$this->view->a = $this->getOneA($id);
$this->loadModel('b');
$this->view->b = $this->model->getOneB($id);
$this->view->render('app/teste');
}
The above scenario returns me the expected, takes the data of A and B and makes them available to the View.
It is correct to use this method ?
If yes, I should load the Model "b" into the controller’s __Construct "a" or directly into the controller’s function "a" as in this example?
If not, what is the best way to get data from different models?
NOTE: All controllers are children of the main controller and all models are children of the main model.