unable to load model using hmvc in codigniter.
Here is my controller users.php (application/modules/users/controllers/users.php)
class Users extends MX_Controller {
public function index(){
$this->load->view('users_view');
}
public function test(){
$this->load->model('model/mdl', TRUE);
$data['result']=$this->mdl->listTable();
$this->load->view('pages/listTable', $data);
}
}
and the model mdl.php (application/modules/users/model/mdl.php)
class Mdl extends CI_Model{
function listTable(){
$this->db->select('*');
$this->db->from('users');
$query = $this->db->get();
if($query) return $query->result_array();
else return false;
}
}
all i am getting is
Unable to locate the model you have specified: mdl
my PHP version is 5.1.6 and CI: 2.1.4
You should be able to load the model like this, if it's in the same module:
$this->load->model('mdl');
Or, if you want to load the model from a different module, you need to specify the module that the model belongs to in the path, like this:
$this->load->model('users/mdl');
When you want to load a model, here's the best syntax if you load the model in the same module :
$this->load->model('mdl_model');
And if you want to load it from a different module :
$this->load->model('users/mdl_model');
Please check model file name and class name must be start with capital latter and $this->load->model('users/Mdl','mdl');
Pass second parameter for converting model name
your modelfile naming must be Mdl.php