[Solved] query in codeigniter: get where or


You can use the where_in method as a shortcut to multiple or-statements for the same column:

$available_ids = [1, 2, 3];

$this->db->where_in('id', $available_ids);
// WHERE id IN (1, 2, 3)

If you were looking to check multiple columns (the name is ‘Adam’ or the title is ‘Grand Poobah’ or the status is ‘Active’), you can use the or_where method instead:

$this->db->where('name', $name);
$this->db->or_where('title', $title);
$this->db->or_where('status', $status); 
// WHERE name="Adam" OR title="Grand Poobah" OR status="Active"

To put it all together, you’d

$available_ids = [1, 2, 3];

$query = $this->db->select('*')->from('bla')->where_in('id', $available_ids)->get();
// SELECT * FROM bla WHERE id IN (1, 2, 3)

CodeIgniter v3 Reference
CodeIgniter v2 Reference

2

solved query in codeigniter: get where or