![]() |
Not Finding My 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: Not Finding My Model (/showthread.php?tid=52186) |
Not Finding My Model - El Forum - 05-31-2012 [eluser]hitraj47[/eluser] CI doesn't seem to want to find my model in one of my controllers. I get this message: Quote:A PHP Error was encountered Here is a partial version of controllers/admin.php (I have made a comment next to line 19): Code: <?php And I have my model located here: models/page_model.php. Here is a partial version of page_model.php: Code: <?php The thing is, I have another controller called 'Page' and that also uses the Page Model and that seems to work perfectly fine. I don't know why it won't work here. If you need any more code please let me know. Not Finding My Model - El Forum - 05-31-2012 [eluser]CI_expert_indian[/eluser] provide the code for controller "page" please Not Finding My Model - El Forum - 05-31-2012 [eluser]hitraj47[/eluser] Here is the code for controllers/page.php" Code: <?php Not Finding My Model - El Forum - 05-31-2012 [eluser]CI_expert_indian[/eluser] $data['pages_list'] = $this->page_model->get_page_list_admin(); ..... try to call another function and then check is really page_model not load here or is there any other problem in that function .. Not Finding My Model - El Forum - 06-01-2012 [eluser]hitraj47[/eluser] [quote author="deep_sheera" date="1338531590"] $data['pages_list'] = $this->page_model->get_page_list_admin(); ..... try to call another function and then check is really page_model not load here or is there any other problem in that function ..[/quote] I made a function called test() in my page_model.php: Code: public function test() { Then I assigned $data['pages_list'] to $this->page_model->test(); and I got the same error, this time PHP is saying Fatal error: Call to a member function test() on a non-object Then when I changed it back to Code: $data['pages_list'] = $this->page_model->get_page_list_admin(); I even changed it to one of the functions that already existed in the page_model that works in my Page controller and I still get the same error. EDIT: Wow I just fixed it... In my admin.php controller I had: Code: public function __construct() { As you can see I load the page_model last... I moved that up to the top so now it says: Code: public function __construct() { This fixed the errors... I don't know why this worked, can someone explain it? Should models/helpers and libraries etc that are loaded in the constructor be loaded in a certain order? Not Finding My Model - El Forum - 06-03-2012 [eluser]CI_expert_indian[/eluser] hitraj ![]() |