【发布时间】:2012-01-18 18:46:50
【问题描述】:
下面的活动记录代码没有像我需要的那样对 WHERE 子句进行分组...
$this->db->where('customers_id',$this->user->getCurrentUserProperty('id'))
$this->db->like('delivery_name', $this->input->post('search'));
$this->db->or_like('customers_company', $this->input->post('search'));
$this->db->or_like('customers_company2', $this->input->post('search'));
$this->db->or_like('customers_company3', $this->input->post('search'));
$this->db->or_like('customers_company4', $this->input->post('search'));
这会生成
WHERE `customers_id` = 31509 AND `delivery_name` LIKE '%str%' OR `customers_company` LIKE '%str%'"
我需要在输出周围加上括号,如下所示...我该怎么做?
WHERE `customers_id` = 31509 AND (`delivery_name` LIKE '%str%' OR `customers_company` LIKE '%str%')"
注意:我讨厌这样烦人的活动记录
如果我使用下面的方法,我怎样才能清理输入,使其不是原始的查询?
$where = "name='Joe' AND status='boss' OR status='active'";
$this->db->where($where);
【问题讨论】:
标签: php codeigniter activerecord