Welcome Guest, Not a member yet? Register   Sign In
model not loading :(
#1

[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
#2

[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.
#3

[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();    
    }




Theme © iAndrew 2016 - Forum software by © MyBB