2014-09-15 1 views
1

안녕하세요. codeigniter를 처음 사용했습니다. 컨트롤러 내부에서 모델을로드하려고하는데 Fatal error: Class 'application\models\CI_Model'을 찾을 수 없습니다. 내가 모델을로드하기 전에 뭔가를 설정해야합니까
codeigniter로드 모델 오류

내 컨트롤러 :

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

코드가 잘 찾고 있습니다. 모델을로드하는 동안 TRUE를 패스 한 특별한 이유가 있습니까? –

+0

모델 파일의 이름은 무엇이며 응용 프로그램에서 파일의 위치는 무엇입니까? –

+0

TRUE를 전달하는 이유는 DB에 연결하기위한 것입니다. – user3041833

답변

0

확인 다음 사항 -

  • 그것은 분명 system/core/Model.php에 있어야 클래스 CI_Model을 찾을 수 없다는 것.

  • 확실히 파일이 여전히 존재하고 filename 어떤 이유로 변경, 파일 내에 typo이 없음을하지 않은합니다. 주요 index.php (applicationssystem 디렉토리 외부에있는 것)에서
  • , $system_path가 올바르게 설정되어 있는지 확인합니다.

  • 모델 파일이 applications/models/ 디렉토리에 file name 같은 즉 class name로 user.php에게 내 IDE 네임 스페이스 응용 프로그램의 \ 모델을 추가하여 도움을

+0

좋아요. 좋아 보이는 모든 것을 모두 완료했습니다. 모두 제 위치에서 유용합니다. – user3041833

+1

첫 번째 점이 유용하다고 생각합니다. –

0

감사를해야한다; 그게 문제가되었습니다