CodeIgniter Forums
model not loading :( - 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: model not loading :( (/showthread.php?tid=1713)



model not loading :( - El Forum - 06-21-2007

[eluser]Unknown[/eluser]
Hi everyone.

I'm having a problem getting a model to load. I'm getting this error:
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: User::$load
Filename: controllers/user.php
Line Number: 6

Fatal error: Call to a member function model() on a non-object in C:\dev\xampplite\htdocs\ci\system\application\controllers\user.php on line 6

And here is my Controller
Code:
<?php
class User extends Controller {
    
    function user()
    {
        $this->load->model('User_model');
        $this->validateLoginStatus();
    }
    ....
Any idea's on why I might be getting this error?

Thanks.
Any idea


model not loading :( - El Forum - 06-21-2007

[eluser]Unknown[/eluser]
Well, it looks like I can't load a model within the constructor.

Is there anyway to have a callback like "beforeFilter" in cakePhp?

Thanks again.


model not loading :( - El Forum - 06-22-2007

[eluser]Bulk[/eluser]
I don't know if you just left it out for brevity, or if you left it out of the actual code, but you need a constructor function that calls the contructor for the "Controller" class - or the global classes won't get attached, eg:

Code:
function User()
    {
        parent::Controller();    
    }