public function vsearch($q){
        $keywords = '%'.$q.'%';
        $where['title|content'] = array('like',$keywords);  //用like条件搜索title和content两个字段
        $where['type']=2;
        $Mposts=new \Home\Model\PostsModel;
        $resarr=$Mposts->vsearch($where);
        $this->assign('resarr',$resarr);
        $this->display();
    }

模型中的是

public function vsearch($where){
		return $this->where($where)->select();
	}