[eluser]awpti[/eluser]
I didn't like the logic of how getRole() worked, so I changed it to return true/false (makes more sense than returning the actual result to me).
Code:
function get_role($role)
{
$this->CI->db->select('otn_roles.name');
$this->CI->db->JOIN('otn_roles', 'otn_users.role_id = otn_roles.id');
$query = $this->CI->db->getwhere('otn_users', array('otn_users.id'=>$this->CI->session->userdata('user_id')), 1, 0);
$row = $query->result();
if ($row->name === $role)
{
return TRUE;
}
else
{
return FALSE;
}
}
if($row->name === $role).. returns:
Severity: Notice
Message: Trying to get property of non-object
Filename: libraries/Erkanaauth.php
Line Number: 136
I don't get it. var_dump of $row:
array(1) { [0]=> object(stdClass)#26 (1) { ["name"]=> string(5) "admin" } }
What the heck am I missing?