phpmysqlcodeigniteractiverecordwhere-in

Codeigniter active record query WHERE column equals a nominated value and another column is one of a few values


I need a query that looks like:

select *
from table
where id=5
    and (eid = 1 or eid = 2 or eid = 10)

and I have tried

$this->db->select()->from(MEMB_EVENTS);
$this->db->where('mID', $mID);

I've tried various things with where(), or_where(), and get_where() but with no success in getting the needed parenthetical grouping.


Solution

  • I think You can do that by using something like

    $this->db->select()->from(MEMB_EVENTS);
    $this->db->where('mID', $mID);
    $this->db->where("(eid='1' OR eid='2' OR eid='10')", NULL, FALSE);