Welcome Guest, Not a member yet? Register   Sign In
Model loading problem
#1

[eluser]Nial[/eluser]
I have a model, Job_handler, which calls a second model, User_handler.

I have number of models which all load fine. For some reason, I receive an error when trying to load User_handler. I receive the following error:
Quote:Call to a member function fetch_tags() on a non-object
.

Obviously, this means that User_handler isn't being loaded correctly. I've also manually checked and its constructor is never triggered. I'm sure this is some simple error I've missed, but right now I'm pulling my hair out!

Job_handler model file (job_handler.php):
Code:
class Job_handler extends Model {

    function Job_handler() {
        parent::Model();
    }
    
    function fetch( $page ) {
        
        $this->load->model('User_handler');
        $this->User_handler->fetch_tags();

    }
}

User_handler model file (user_handler.php):
Code:
class User_handler extends Model {

    function User_handler() {
        parent::Model();
    }
    
    function fetch_tags() {
        
        // Yadda yadda
        
    }
    
}
#2

[eluser]flojon[/eluser]
I think you need to do:
Code:
$CI =& get_instance();
$CI->load->model('User_handler');

since you're not in a controller




Theme © iAndrew 2016 - Forum software by © MyBB