Message: Undefined property: Category::$category_m
Fatal error: Call to a member function getNumCategory() on a non-object in C:\wamp\www\system\application\controllers\category.php on line 15
controllers\category.php
Code: Select all
class Category extends Controller{
function Category(){
// load controller parent
parent::Controller();
// load 'Categorys' model
$this->load->model('category_m','category');
$this->load->database();
$this->load->helper('url');
$this->load->helper('form');
}
function index(){
$this->load->database();
$data['numCategory']=$this->Category_m->getNumCategory();
$data['title']='Displaying Category data';
$data['header']='Category List';
// load 'Categorys_view'
$this->load->view('category_view',$data);
}
}
Code: Select all
class Category_m extends Model{
function Category_m(){ // call the Model constructor
parent::Model(); // load database class and connect to MySQL
$this->load->database();
}
// get all Category
function getCategory(){
$query=$this->db->get('category');
if($query->num_rows()>0){ // return result set as an associative array
return $query->result_array();
}
}
// get total number of Category
function getNumCategory(){
return $this->db->count_all('category');
}
}
i have done autoload database also.
PLZZZZZZ help..