用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1380|回复: 0
收起左侧

[HELP] 怎么设置wheret条件

[复制链接]
发表于 2013-10-12 17:53:24 | 显示全部楼层 |阅读模式
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 的条件加上 括号


本版积分规则