loading models within models not allowed in CI 2.0.2? Go back to 1.7.2? - 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 models within models not allowed in CI 2.0.2? Go back to 1.7.2? (/showthread.php?tid=43439) |
loading models within models not allowed in CI 2.0.2? Go back to 1.7.2? - El Forum - 07-11-2011 [eluser]Xerix[/eluser] Hello All, I have a peculiar problem. I get 'Fatal error: Call to a member function model() on a non-object in C:\Programming\www_root\passport\models\pages_model.php on line 15' My directory structure for my 2 projects is +www_root ----+passport (my app that doesnt work!) ----+cmt (my app that does work!) ----+system (Codeigniter 2.0.2) code that generates error Code: class Pages_model extends CI_Model{ I thought you fixed this problem from CI 1.7.2? Any Ideas? I upgraded to get around the problem of loading Models within Models. Is there something I need to change in my config somewhere. Also I am extending and constructing my classes properly using CI_Controller, CI_Model and using parent::__construct within the __construct function. I have been pulling my hair out for 2 days now. Any help is much appreciated before I abandon CI 2. Thanks loading models within models not allowed in CI 2.0.2? Go back to 1.7.2? - El Forum - 07-11-2011 [eluser]danmontgomery[/eluser] Was this ever allowed? You can load the menus_model before you load pages_model, in which case it's accessible like anything else, or: Code: $ci = get_instance(); loading models within models not allowed in CI 2.0.2? Go back to 1.7.2? - El Forum - 07-11-2011 [eluser]Xerix[/eluser] Sorry, I should have been more specific. No it was not allowed in 1.7.2. And I used the above method. However, I am trying to use the new way as I have my new cmt project I am making and would like to use it. Any Ideas? loading models within models not allowed in CI 2.0.2? Go back to 1.7.2? - El Forum - 07-11-2011 [eluser]danmontgomery[/eluser] 2 ideas... The ones I suggested loading models within models not allowed in CI 2.0.2? Go back to 1.7.2? - El Forum - 07-11-2011 [eluser]Xerix[/eluser] LOL, I was afraid you might say something like that. No worries, not a big deal. Out of curiosity, does CI2+ support calling $this->load->model within another model? Thanks loading models within models not allowed in CI 2.0.2? Go back to 1.7.2? - El Forum - 07-11-2011 [eluser]danmontgomery[/eluser] Huh. I could have sworn you couldn't, but I just tested in Reactor and you can. The error you're seeing is that load isn't an object. I would assume you can't load anything? loading models within models not allowed in CI 2.0.2? Go back to 1.7.2? - El Forum - 07-11-2011 [eluser]Xerix[/eluser] I just checked and load is in fact null. Shouldn't the base model class CI_Model handle the creation of load? as in $this->load is not null? Andrew |