我需要做类似这个 sql 查询的事情,但是在 codeigniter 中:
SELECT `table`.* FROM (`table`) WHERE `name` LIKE '%9%' OR `id` LIKE '%9%' AND (`name` LIKE '%f%' OR `id` LIKE '%f%')
我试图做这个代码:
$this->db->select('table.*');
$this->db->from('table');
foreach($data as $d){
$this->db->like("name", $d)
$this->db->or_like("id", $d);
}
但是sql中的结果是:
SELECT `table`.* FROM (`table`) WHERE `name` LIKE '%9%' OR `id` LIKE '%9%' AND `name` LIKE '%f%' OR `id` LIKE '%f%'
谢谢