CodeIgniter Forums
[Solved] $user_query not returning row in library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: [Solved] $user_query not returning row in library (/showthread.php?tid=60724)



[Solved] $user_query not returning row in library - El Forum - 06-14-2014

[eluser]riwakawd[/eluser]
My login function in my Users library is not getting the $user_query row. I thought I got this correct.

Code:
$data = array(
    'user_id' => $this->user_id,
    'username' => $this->username
);

$this->CI->session->set_userdata($data);

$this->CI->session->userdata('user_id') = $user_query->row('user_id');

$this->user_id = $user_query->row('user_id');
$this->username = $user_query->row('username');

User.php Library

Code:
public function login() {

$user_query = $this->CI->db->query("SELECT * FROM " . $this->CI->db->dbprefix . "user WHERE username = '" . $this->CI->db->escape($username) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->CI->db->escape($password) . "'))))) OR password = '" . $this->CI->db->escape(md5($password)) . "') AND status = '1'");

if ($user_query->num_rows() == 1) {

$data = array(
    'user_id' => $this->user_id,
    'username' => $this->username
);

$this->CI->session->set_userdata($data);

$this->CI->session->userdata('user_id') = $user_query->row('user_id');

$this->user_id = $user_query->row('user_id');
$this->username = $user_query->row('username');  

$user_group_query = $this->CI->db->query("SELECT permission FROM " . $this->CI->db->dbprefix . "user_group WHERE user_group_id = '" . (int)$user_query->row('user_group_id') . "'");

$permissions = unserialize($user_group_query->row('permission'));

if (is_array($permissions)) {
    foreach ($permissions as $key => $value) {
    $this->permission[$key] = $value;
  }
}

return true;

} else {

return false;

}
    
}




[Solved] $user_query not returning row in library - El Forum - 06-14-2014

[eluser]riwakawd[/eluser]
I am paying a developer to look into it and fix my issues.


[Solved] $user_query not returning row in library - El Forum - 06-17-2014

[eluser]joergy[/eluser]
hm,

what do You want by this:

Code:
$this->CI->session->set_userdata($data);

$this->CI->session->userdata('user_id') = $user_query->row('user_id');

?