我的控制器是
public function login_process()
{
$this->load->library('session');
$data=array(
'username'=>$this->input->post('userName'),
'password'=>md5($this->input->post('userPwd'))
);
$result = $this->Admin->login($data);
if ($result == TRUE)
{
$session_data = array(
'userId' => $result[0]->user_id,
'username' => $result[0]->user_name,);
$this->session->set_userdata('logged_in', $session_data);
$this->load->view('header');
}
else
{
$data['msg'] = array(
'error_message' => 'Invalid Username or Password'
);
$this->load->view('index',$data);
}
}
我的模特是
class Admin extends CI_model
{
// Read data using username and password
public function login($data)
{
$this->db->select('*');
$this->db->from('users');
$this -> db -> where('user_name', $data['username']);
$this -> db -> where('user_password ',$data['password']);
$this->db->limit(1);
var_dump($this->db);
$query = $this->db->get();
if ($query->num_rows() == 1)
{
return true;
}
else
{
return false;
}
}
}
我收到以下错误
Error Number: 1054
'where子句'中的未知列'user_name'
SELECT * FROM(users
)WHERE user_name
='ddddd'和user_password
='xxx'LIMIT 1
文件名:C:\ xampp \ htdocs \ pranasInventory \ system \ database \ DB_driver.php
行号:330
请帮帮我