• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI can't find my method and I don't know why...

#1
Hi all, I have a project in Ci and I can't get it to recognize my check2() for some reason. CI keeps throwing Fatal error: Call to undefined method CI_Loader::check2()

controller (Login.php)
PHP Code:
class Login extends CI_Controller {
    
    public function 
index() {
        
// Page variables
        
$page['title'] = "Analytics Login";      
        
$this->load->view('header'$page);    
        
$this->load->view('login');
        
$this->load->view('footer');
    }
  
    public function 
verify() {
        
        
$verifier     $this->load->model('Verifylogin_model');
        
        
$username $this->input->post('username');
        
$password $this->input->post('password');
        
        if((!
$verifier->check2($username,$password))) {
            
$this->load->view('login');
        } else {
            
redirect('home''refresh');    
        }
    }


Model (verifylogin_model.php)
PHP Code:
<?php
Class Verifylogin_model extends CI_Model {
    
    function 
__construct() {
        
parent::__construct();
    }

    public function 
check2($username$password) {
        
        
$this->db->select('user_id, user_email');
        
$this->db->from('admin_users');
        
$this->db->where('user_email'$username);
        
$this->db->where('user_pass'md5($password));
        
$this->db->limit(1);
        
        
$results $this->db->get();
    
        if (
$results->num_rows() == 1) {
            return 
true;
        } else {
            return 
false;
        }
    }
}
?>


Any feedback is welcome
Reply

#2
$this->load->model() calls don't return the models that you're requesting.

http://www.codeigniter.com/userguide3/li...der::model
Reply

#3
Because this is not how you use models.
Method "model" of CI_Loader returns an instance of it self(CI_Loader), not an instance of the model. The model is instantiated in the controller property with the same name as the model, or in coder words: $this->Nameofmodel_model

Please read:
http://www.codeigniter.com/user_guide/ge...ng-a-model
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.