It used to be that within a CodeIgniter model you couldn't access another model.
$this->load->model('bar'); $this->bar->something();
Is this still valid, or have they changed it?
Auto-loading Models If you find that you need a particular model globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization. This is done by opening the application/config/autoload. php file and adding the model to the autoload array.
First Model interacts withe the database. Then load the model and access relevant function in your controller. Finally load the data to view from the controller. That's it...you can show the data simply in a foreach loop.
Instead of CI3's $this->load->model(x); , you would now use $this->x = new X(); , following namespaced conventions for your component. Alternatively, you can use the model function: $this->x = model('X') ;.
Those are some VERY long answers for a simple question.
Short answer: This is now fully supported. Cross-load away if you feel like it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With