无法找到您指定的模型:model_users

时间:2014-01-04 10:26:27

标签: php codeigniter

这是我的模型代码

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Model_users extends CI_Model() {

    public function can_log_in(){

        $this->db->where('email',$this->input->post('email'));
        $this->db->where('password',md5($this->input->post('password')));

        $query = $this->db->get('users');

        if($query->num_rows()==1){
            return true;
        } else {
            return false;
        }

    }
}

?>

这是控制器的代码

public function validate_credentials(){
    $this->load->model('model_users');

     if($this->model_users->can_log_in()){
        return true;
     } else {
        $this->form_validation->set_message('validate_credentials','Incorrect username/password');
        return false;
     }
}

1 个答案:

答案 0 :(得分:1)

您的模型名称为Model_users,您正在加载model_users。仔细阅读the documentation