Welcome Guest, Not a member yet? Register   Sign In
Call to a member function ... on a non-object
#1

[eluser]bigdaddysheikh[/eluser]
I am having trouble instantiating my models. I get
Code:
Call to a member function getAll() on a non-object
error even though the same model works in other controllers.

here is my controller that is calling the model.

Code:
<?php

class Welcome extends Controller {
    function Weclome()
    {
        parent::Controller();    
        $this->load->helper(array('form','url'));
        $this->load->database();    
        $this->load->model("pages");
    }
    
    function index()
    {
        $data["listing"] = $this->pages->getAll();
        $this->load->view("index", $data);
    }
}

here is the model:
Code:
<? class Pages extends Model {

    var $title   = '';
    var $content = '';
    var $date    = '';

    function Pages()
    {
        // Call the Model constructor
        parent::Model();
        $this->load->helper('form');        
    }
    
    function getAll()
    {
        $query = $this->db->get('page');
        return $query->result();
    }

What can be the problem? The same model and lines work in my other admin controllers.

Thanks in advance for helping.


Messages In This Thread
Call to a member function ... on a non-object - by El Forum - 01-11-2009, 05:31 PM
Call to a member function ... on a non-object - by El Forum - 01-11-2009, 05:51 PM
Call to a member function ... on a non-object - by El Forum - 01-12-2009, 03:22 AM
Call to a member function ... on a non-object - by El Forum - 01-12-2009, 11:32 AM
Call to a member function ... on a non-object - by El Forum - 01-12-2009, 07:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB