我在控制器中加载一个模型。但我有一个错误:
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;
}
}
怎么了?非常感谢:)
这样做:
$time = $captcha['time'];
$ip_address = $this->input->ip_address();
$word = $captcha['word'];
$this->load->model('captcha_model/captcha_insert');
$value = $this->captcha_model->captcha_insert($time, $ip_address, $word);