awen3616137 发表于 2013-10-12 17:53:24

怎么设置wheret条件

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 的条件加上 括号


页: [1]
查看完整版本: 怎么设置wheret条件