where condition role. |
Hi Coders,
i have user table with role, ADMIN AND USER now i have a one page, that if the user login as user, he/she can view his own work while if the user login as admin he can view all user works? any body how to implement it. wrong condition.... PHP Code: $this->db->where('users.fname',$this->session->userdata['logged_in']['fname'] AND 'users.role','admin');
01-08-2015, 01:49 AM
(This post was last modified: 01-08-2015, 02:31 AM by Jamie. Edit Reason: Added example ) PHP Code: $array = array('fname' => $this->session->userdata['logged_in']['fname'], 'role' => 'admin'); or PHP Code: $this->db->where('fname',$this->session->userdata['logged_in']['fname']); Please see the documentation: CI3|CI2 Hope this is of some help. Edit: On reflection the get_where() function may be neater to use. PHP Code: $query = $this->db->get_where('users', array('fname' => $this->session->userdata['logged_in']['fname'], 'role' => 'admin')); An alternative way you could implement this is as follows: PHP Code: $query = $this->db->select('fname,role')->get_where('users', array('fname' => $this->session->userdata['logged_in']['fname']));
Jamie Bond
Full time International Development undergraduate. Part time website developer. |
Welcome Guest, Not a member yet? Register Sign In |