消息:在布尔上调用成员函数row()

时间:2019-05-19 09:41:05

标签: php mysql codeigniter

我是CodeIgniter和PHP的新手,请为我提供帮助吗? 我无法登录,并且不断告诉

  

遇到未捕获的异常

     

类型:错误

     

消息:在bool上调用成员函数row()

     

文件名:C:\ xampp \ htdocs \ poslite \ application \ models \ UsersModel.php

     

行号:36

class UsersModel extends CI_Model {

    public function insert_account ($username,$password,$account_type,$date_created,$created_by) {
        $encrypt_password = password_hash($password,PASSWORD_DEFAULT);
        $data = array(
            'username' => "$username",
            'password' => "$encrypt_password",
            'account_type' => "$account_type",
            'date_created' => "$date_created",
            'created_by' => "$created_by"
            );
        $data = $this->security->xss_clean($data);
        return $this->db->insert('users', $data);
    }

    public function display_accounts() {

        $this->db->order_by('id','DESC');
        $sql = $this->db->get('users');
        return $sql->result();
    }

    public function delete_account($id) {
        $id = $this->security->xss_clean($id);
        $this->db->where('id',$id);
        $del = $this->db->delete('users');
        return $del;
    }

    public function login($username) {  
        $this->load->database();
        $sql = $this->db->where('username',$username)
                        ->get('users');
        return $row = $sql->row();

    }
}

我希望可以登录,但是由于这个错误我无法登录。

0 个答案:

没有答案