Welcome Guest, Not a member yet? Register   Sign In
Issues loading models
#1

[eluser]Unknown[/eluser]
Hey everyone, first time caller!

I am working though the Wrox Professional Codeigniter book and I am running into a small snag. I worked through chapter 3 and got everything configured, the models, the controller and the views setup. However when I try and and run the app I get the following message

Fatal error: Call to undefined method MCats::getCategoriesNav() in F:\xampp\htdocs\CI\system\application\controllers\welcome.php on line 13\

here is what the code looks like for the index function on the controller which is welcome.php

Code:
lass Welcome extends Controller {

    function Welcome(){
        parent::Controller();
        
    }
    
    function index(){
        
        $data['title'] = "Welcome to Claudia's Kids";
        $data['navlist'] = $this->MCats->getCategoriesNav();
        $this->load->vars($data);
        $this->load-view('template');
    }

...


here is a snippet of my mcats.php file which where the model in question is at

Code:
function getCategoriesNav() {
    $data = array();
    $Q = $this->db->get('categories');
    
    if ($Q->num_rows() > 0){
        foreach ($Q->result_array() as $row) {
            $data[$row['id']] = $row['name'];
            }
    }

    $Q->free_result();
    return $data;
}

here is what the line in my autoload.php that deals with loading the Models

Code:
$autoload['model'] = array('MProducts', 'MCats');


I am kinda scratching my head on this one, I turned up logging and didn't see anything worth while that could help. It kinda looks like that maybe the model isn't getting loaded properly which would through the undefined method error. I just can't seem to find whats going on with it and sometimes it takes a fresh set of eyes to spot the problem.

Thanks for the help!


Messages In This Thread
Issues loading models - by El Forum - 02-19-2009, 09:39 AM
Issues loading models - by El Forum - 02-19-2009, 10:44 AM
Issues loading models - by El Forum - 02-19-2009, 10:49 AM
Issues loading models - by El Forum - 02-20-2009, 08:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB