我正在编写我的第一个 CodeIgniter 脚本,但我无法加载以下模型,如果有人可以帮助我吗?
这是我的控制器文件:
public function process(){
// Load the model
$this->load->model('users/login', 'users');
// Validate the user can login
$result = $this->users->validate();
// Now we verify the result
if(!$result){
    // If user did not validate, then show them login page again
    $this->index();
}else{
    // If user did validate,
    // Send them to members area
    redirect('home');
}      
}
这是我的模型
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Login_Model extends CI_Model{
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    public function validate(){
        // grab user input
        $username = $this->security->xss_clean($this->input->post('username'));
        $password = $this->security->xss_clean($this->input->post('password'));
        // Prep the query
        $this->db->where('username', $username);
        $this->db->where('password', $password);
        // Run the query
        $query = $this->db->get('users');
        // Let's check if there are any results
        if($query->num_rows == 1)
        {
            // If there is a user, then create session data
            $row = $query->row();
            $data = array(
                    'userid' => $row->userid,
                    'fname' => $row->fname,
                    'lname' => $row->lname,
                    'username' => $row->username,
                    'validated' => true
                    );
            $this->session->set_userdata($data);
            return true;
        }
        // If the previous process did not validate
        // then return false.
        return false;
    }
}
?>
我可以确认进程函数正在加载,但是 $results = $result = $this->users->validate(); 下的任何代码;没有出现。模型也在加载,只要我尝试调用一个函数,脚本就会自行终止。
对不起,如果这个问题有点乏味。
谢谢彼得