duanre1891 2018-03-07 14:46
浏览 34

从模型中的数据库传递值

As part of a login I'm using a key that is held against the user within the 'users' table. I having trouble obtaining the key from the database and then using it to decode the password. I get the key from the users table put it does not what to assign the value to the variable $data, Taking that the value returned from the query would be an array I try reference the $data variable as $data[0] but made no difference.

 public function checklogin($Email,$Pass)
    {
        $data = $this->db->query(select Key from users where User = $Email);

        $Password = $this->encrypt->decode($Pass,$data);

        $this->db->select('User','Pwd','Level');
        $this->db->from('users');
        $this->db->where('User', $Email);
        $this->db->where('Pwd', $Password);
        $this->db->where('Active','Y');

        $query = $this->db->get();      
    }

Var dump returns: object(CI_DB_mysqli_result)#25 (8) { ["conn_id"]=> object(mysqli)#15 (19) { ["affected_rows"]=> int(1) ["client_info"]=> string(79) "mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $" ["client_version"]=> int(50011) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["field_count"]=> int(1) ["host_info"]=> string(20) "localhost via TCP/IP" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(21) "5.5.5-10.1.25-MariaDB" ["server_version"]=> int(50505) ["stat"]=> string(134) "Uptime: 25131 Threads: 2 Questions: 380 Slow queries: 0 Opens: 28 Flush tables: 1 Open tables: 21 Queries per second avg: 0.015" ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(89) ["warning_count"]=> int(0) } ["result_id"]=> object(mysqli_result)#24 (5) { ["current_field"]=> int(0) ["field_count"]=> int(1) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) } ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> NULL ["row_data"]=> NULL }

  • 写回答

1条回答 默认 最新

  • duangan7834 2018-03-07 15:21
    关注

    Replace

    $query = $this->db->get(); 
    

    With the following line

    $query = $this->db->get()->result_array();
    

    More information available at:

    Documentation

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)