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.
$this->db->where_in('id', ['20','15','22','42','86']);
Reference: where_in
Generates a WHERE field IN (‘item’, ‘item’) SQL query joined with AND if appropriate,
$this->db->where_in()
ex : $this->db->where_in('id', array('1','2','3'));
Generates a WHERE field IN (‘item’, ‘item’) SQL query joined with OR if appropriate
$this->db->or_where_in()
ex : $this->db->where_in('id', array('1','2','3'));
From the Active Record docs:
$this->db->where_in();
Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate
$names = array('Frank', 'Todd', 'James');
$this->db->where_in('username', $names);
// Produces: WHERE username IN ('Frank', 'Todd', 'James')
Use where_in()
$ids = array('20', '15', '22', '46', '86');
$this->db->where_in('id', $ids );