hi我是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;
}
}
}
检查以下几点-
-
它显然找不到类
CI_Model
,该类应该在system/core/Model.php
中。 -
请确保该文件仍然存在,并且
filename
由于某种原因没有更改,并且文件中没有typo
。 -
在主目录
index.php
(位于applications
和system
目录之外的目录)中,确保正确设置了$system_path
。 -
您的模型文件应位于
applications/models/
目录中,其file name
与class name
相同,即user.php
感谢您的帮助我的IDE添加了命名空间应用程序''模型;这就是的问题