在codeigniter hmvc中加载模型时出错

时间:2015-02-21 18:45:51

标签: php codeigniter error-handling hmvc

我在控制器中加载模型。但我有这个错误:

Message: Undefined property: Captcha::$captcha_model

还有这条消息:

Fatal error: Call to a member function captcha_insert() on a non-object in C:\xampp\htdocs\ci-framework\application\modules\captcha\controllers\captcha.php on line 31

一切似乎都是真的!

控制器:

$time = $captcha['time'];
$ip_address = $this->input->ip_address();
$word = $captcha['word'];
$this->load->model('captcha/captcha_model');
$value = $this->captcha_model->captcha_insert($time, $ip_address, $word);

模型:

class Captcha_model extends CI_model {


 public function captcha_insert($time, $ip_address, $word){

    $query = $this->db->query("insert into captcha
                                (time, ip_address, word)
                                values(?, ?, ?)",
                                array($time, $ip_address, $word));
    if ($query)
        return true;
 }


}

怎么了? 非常感谢你:))

1 个答案:

答案 0 :(得分:3)

我搜索了更多并找到答案:)

不仅在module/controller中,而且在基地controller中,我必须扩展MX而不是CI。谢谢你们:)