Welcome Guest, Not a member yet? Register   Sign In
Problem call model in controller
#1

[eluser]memVN[/eluser]
I have a model follow
Code:
class Kitchen_model extends CI_Model
{

var $table = 'kitchen';

public function __construct()
{
  parent:: __construct();
}


public function getList($limit = null)
{
  if($limit != null)
  {
   $this->db->limit($limit['max'], $limit['begin']);
   $q = $this->db->get($this->table);
   return $q;
  
   $q->free_result();
  }
}


}
// End class
// File local: application/models/kitchen/kitchen_model.php

And I create a controller - call this model

Code:
class Kitchen extends CI_Controller {

function __construct() {

  parent:: __construct();
  $this->load->model('kitchen/kitchen_model','kitchen');

}


public function index() {

  $data = array();
  $q = $this->kitchen->getList(null);
  $result = $q->result();
  $this->load->view('kitchen/index', $data);  
}

}

Error this line $result = $q->result();
Code:
Call to a member function result() on a non-object in D:\xampp\htdocs\project\haasam\application\controllers\kitchen.php on line 27

I don't known why??? Who can help me




Theme © iAndrew 2016 - Forum software by © MyBB