嗨,我是codeigniter的新手
我试图在控制器内加载一个模型,我得到了
Fatal error: Class 'application\models\CI_Model'
未找到。
在加载模型之前是否需要进行设置
我的控制器:
class VerifyLogin extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->model('user','',TRUE);
}
function index(){
$this->load->library('form_validation');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|min_length[6]');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|is_unique[users.email]');
if ($this->form_validation->run()==false)
{
$this->load->view('header');
$this->load->view('marketing/marketing_custom_header');
$this->load->view('menu_2');
$this->load->view('marketing/marketing');
$this->load->view('footer');
}else{
redirect('home', 'refresh');
}
}
}
我的模特:
class User extends CI_Model {
function __construct(){
parent::__construct();
}
function login($email,$password ){
$this->db ->select('id, email, password');
$this->db -> from('users');
$this->db -> where('email',$email);
$this->db -> where('password',$password);
$this->db -> limit(1);
$query ="";
$query ->$this ->db ->get();
if($query ->num_rows()==1){
return $query->resilt();
}else{
return false;
}
}
}
答案 0 :(得分:0)
检查以下几点 -
显然无法找到应该在 CI_Model
中的课程 system/core/Model.php
。
确保文件仍然存在且 filename
由于某种原因没有更改,并且没有 typo
主要 index.php
(位于 applications
之外且 system
< / strong>目录),确保正确设置 $system_path
。
您的模型文件应位于 applications/models/
目录中file name
与class name
相同,即 user.php
答案 1 :(得分:0)
感谢您的帮助 我的IDE添加了命名空间application \ models; 这就是问题