![]() |
Loading a model inside a model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Loading a model inside a model (/showthread.php?tid=12435) |
Loading a model inside a model - El Forum - 10-19-2008 [eluser]robmcm[/eluser] Hi, I would like to have a model, that loads in various different models. For example if you had a car model, it would load in the engine model, wheel model, interior model etc etc The problem I have is codeigniter doesn't seem to allow me to load a model inside a model. So when inside my car model, if I do the following: Code: $this->load->model('Engine_model', '', TRUE); I get this error: Code: A PHP Error was encountered Is there a different way to load a model, or should my Car_model not really be a model, or at lease extend the codeigniter Model class? Thanks Rob Loading a model inside a model - El Forum - 10-19-2008 [eluser]Mike Ryan[/eluser] Hi Rob, You need to call the engine model via the CI instance: Code: $CI =& get_instance(); Loading a model inside a model - El Forum - 10-19-2008 [eluser]robmcm[/eluser] Thanks Mike! I had just found this: http://ellislab.com/forums/viewthread/49625/#240711 Someone there posted the same solution, seems to work ![]() Thanks Rob |