上一个文章搜索方法

浏览:408 发布日期:2014/05/12 分类:技术分享 关键字: 关键词搜索文章
    /*根据关键词搜索文章*/
    public function search($key = '百岁', $status = 1){

        $perfix = C('DB_PREFIX');

        /*用OR拼接LIKE语句*/
        $map['_logic'] =  'OR';
        $map['title'] =  array('like', '%'.$key.'%');
        $map['description'] =  array('like', '%'.$key.'%');
        $map['id'] =  array('IN', 'SELECT id FROM `'.$perfix.'document_article` WHERE content LIKE %'.$key.'%');
        /*拼接AND语句*/
        $maps['_complex'] =$map; 
        $maps['status'] =  '1';
        $maps['id'] = array('NOT IN', '4,15');

        $temp = $this->field(true)->where($maps)->select();

        dump($temp);

    }
最佳答案
评论( 相关
后面还有条评论,点击查看>>