Pass array to where in Codeigniter Active Record

Daniel White picture Daniel White · Dec 5, 2012 · Viewed 114.2k times · Source

I have a table in my database with adminId and clientId

There might be 20 records with the adminId of the logged in user and I'm trying to pull a list of clients.

I am wondering if there is a way i can say something like:

$this->db->where('id', '20 || 15 || 22 || 46 || 86');

I'm trying to do this with dynamic data (you never know how many clients Id's you'll need to pull). Any ideas?

Answer

joHN picture joHN · Dec 5, 2012
$this->db->where_in('id', ['20','15','22','42','86']);

Reference: where_in