I'm using the framework CodeIgniter 3 with HMVC extension and I can't load model. When I try do it, I see next error: Unable to locate the model you have specified: Protection.
Model file (protection.php) placed at /application/modules/main/models/ and extends this code:
class Protection extends MX_Model
{
function Protection()
{
parent::Model();
}
function check($val)
{
$tpl = "![^\w\d\s]*!";
if(is_array($val))
{
foreach($val as $k => $v)
{
$val[$k] = preg_replace($tpl,"",$v);
}
}
else
{
$val = preg_replace($tpl,"",$val);
}
return $val;
}
}
Controller file placing at /application/modules/main/controllers/ with this code for load model and call her function:
$this->load->model('protection');
$gj = "I'--m_Y%ou#r-Fat/+her";
$this->prt->check($gj);
echo $gj;
I tried rename model file, place his in other folders, but all it was failed.
HMVC models should extend CI_Model only the controller use MX_ on controller And also for a model name instead of just having protection as model name I think would be best to have model_protection so codeigniter will not get confused.
On the constructor
Not use
parent::Model();
But use
parent::__construct();
Like in my exampleOn controller
File name Model_protection.php
Tip all controllers and models and libraries should have there first letter as uppercase on file name and classname