What I am trying to do is search my privileges table where db_id column holds which database a user has rights to. From that database I want to pull all the user_id that have a db_id... ie: 2.
I then want to search my user table for those user_id and list all of their details.
The problem I can not solve is getting the array of user_ids in where where statement.
Please see the included code. Any advice would be greatly appreciated.
Code:
function return_users(){
$this->db_core->where('db_id', $this->session->userdata("db_id"));
$this->db_core->select('user_id');
$query = $this->db_core->get('privileges');
foreach($query->result() as $row) {
$priv[] = $row->user_id;
};
$this->db_core->where('user_id', $priv);
$list_users = $this->db_core->get('users');
$list_users->result_array();
return $list_users->result();
}