帮助在codeigniter中写入查询的哪个部分

时间:2011-02-24 03:28:20

标签: mysql codeigniter activerecord

我使用codeigniter活动记录类编写了一个查询。

编写查询时,它看起来像

WHERE `account` = 1 
AND cgl.contactId IS NULL 
AND `firstName` LIKE 'M%' 
OR `lastName` LIKE 'M%'

但我需要它看起来像

WHERE `account` = 1 
AND cgl.contactId IS NULL 
AND (`firstName` LIKE 'M%' 
OR `lastName` LIKE 'M%') //notice the brackets

我该怎么做?

1 个答案:

答案 0 :(得分:0)

$this->where(array('account' => 1, 'cgl.contactId' => NULL);
$this->where(("firstName` LIKE 'M%' OR `lastName` LIKE 'M%'"))