在嵌套类似查询时,我可能需要一点帮助。我的目标是完成类似以下的事情:
Select * from 'Library_Book'
WHERE(
('BookName' LIKE '%FILTER1%' OR 'BookDescription' LIKE '%FILTER1%')
AND
('BookName' LIKE '%FILTER2%' OR 'BookDescription' LIKE '%FILTER2%')
)
到目前为止,我的方法是:
$this->db->select('Library_Book.*');
foreach($filter as $fltr){
$this->db->like('Library_Book.BookName', $fltr);
$this->db->or_like('Library_Book.BookDescription', $fltr);
}
$records = $this->find_all();
这导致:
Select * from 'Library_Book'
WHERE(
'BookName' LIKE '%FILTER1%' OR 'BookDescription' LIKE '%FILTER1%'
AND
'BookName' LIKE '%FILTER2%' OR 'BookDescription' LIKE '%FILTER2%'
)
我怎样才能得到我的 or_like 语句周围的括号?
谢谢
图奇达蒙
#CI-BONFIRE 版本 0.7
模块/mymodul/models/mymodel_model.php