|
SELECT * FROM (`vf_news`) WHERE `id` != '336' and (`news_tags` LIKE '%运营%' OR `news_tags` LIKE '%心得%' OR `news_tags` LIKE '%公众%') LIMIT 5
怎么才能生成这样的sql语句 ..
我写的where方法
function get_all_like($table ,$where=array(), $fields = '*',$like=array(),$limit='')
{
if($where){
$this->db->where($where);
}
if($like){
foreach($like as $k=>$v){
foreach($v as $i=>$j){
$this->db->or_like($i,$j);
}
}
}
if($limit){
$this->db->limit($limit);
}
return $this->db->select($fields)->from($table)->get()->result_array();
}
得到的sql语句是
SELECT * FROM (`vf_news`) WHERE `id` != '336' and `news_tags` LIKE '%运营%' OR `news_tags` LIKE '%心得%' OR `news_tags` LIKE '%公众%' LIMIT 5
要怎样才能给后面 like 的条件加上 括号
|
|