SELECT rows with specific combinations of values in two columns using CodeIgniter's query builder
12:41 13 Aug 2012

Is there any way to get nested where clauses? e.g.:

SELECT * FROM table WHERE (colA = 'valueA' AND colB = 'valueB') OR (colA = 'valueC' AND colB = 'valueD')

I know I could just write this into a query function call e.g.:

$this->db->query("SELECT ...")

But I was wondering if there was a "proper" way to do it in codeigniter e.g.:

$this->db
    ->where(
        array('colA' => 'valueA'),
        array('colB' => 'valueB')
    )
    ->or_where(
        array('colA' => 'valueC'),
        array('colB' => 'valueD')
    );
php codeigniter where-clause query-builder logical-grouping