Selecting from database based on another query - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: Selecting from database based on another query (/showthread.php?tid=75372) |
Selecting from database based on another query - jldesign - 01-30-2020 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(){ RE: Selecting from database based on another query - nicojmb - 01-31-2020 (01-30-2020, 05:49 PM)jldesign Wrote: 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. Hi, to search in array filed, you need to change to "where_in": PHP Code: $this->db_core->where('user_id', $priv); RE: Selecting from database based on another query - InsiteFX - 01-31-2020 Try this one. PHP Code: $this->db_core->where_in('user_id', $priv); |