严重程度:4096
消息:类Login_Model的对象无法转换为字符串
文件名:models / login_model.php
行号:27
public function login() {
//check user type
$this->_table_name = 'tbl_employee_login';
$this->_order_by = 'employee_login_id';
$employee = $this->get_by(array(
'email' => $this->input->post('email'),
'password' => $this->$this->input->post('password'), LINE NUMBER 27
'activate' => 1
), TRUE);
/*employee*/
$this->_table_name = 'driver';
$this->_order_by = 'driver_id';
$driver = $this->get_by(array(
'email' => $this->input->post('email'),
'password' => $this->$this->input->post('password'),
), TRUE);
/*driver*/
$this->_table_name = 'tbl_user';
$this->_order_by = 'user_id';
$admin = $this->get_by(array(
'email' => $this->input->post('email'),
'password' => $this->$this->input->post('password'),
), TRUE);
if ($admin) {
$data = array(
'email' => $admin->email,
'first_name' => $admin->first_name,
'last_name' => $admin->last_name,
'employee_id' => $admin->user_id,
'loggedin' => TRUE,
'user_type' => 1,
'user_flag' => $admin->flag,
'url' => 'admin/dashboard',
);
$this->session->set_userdata($data);
} elseif($employee) {
if (count($employee)) {
// Log in user
$employee_id = $employee->employee_id;
$this->_table_name = "tbl_employee"; //table name
$this->_order_by = "employee_id";
$user_info = $this->get_by(array('employee_id' => $employee_id), TRUE);
$data = array(
'email' => $employee->email,
'employee_id' => $employee->employee_id,
'user_name' => $user_info->first_name . ' ' . $user_info->last_name,
'employee_login_id' => $employee->employee_login_id,
'loggedin' => TRUE,
'user_type' => 2,
'url' => 'employee/dashboard',
);
$this->session->set_userdata($data);
}
}
elseif($driver){
$data = array(
'email' => $driver->email,
'drive_id' => $driver->driver_id,
'name' => $driver->name,
'loggedin' => TRUE,
'user_type' => 3,
'url' => 'driver/dashboard',
);
$this->session->set_userdata($data);
}
}
任何人都可以给我一个解决这个错误的解决方案。我尝试使用管理员用户名和密码登录,但它向我显示此更多错误,如字符串转换
答案 0 :(得分:2)
有typo
次$this
'password' => $this->$this->input->post('password'),
更改为
'password' =>$this->input->post('password'),
注意:许多same mistake
中的other lines
也会照顾到这一点。
答案 1 :(得分:1)
应为$ this-> input-> post('password')
答案 2 :(得分:1)
您在代码中的3个位置输入错误,即$ this-> $ this。