where(['name'=>$param['s']])->value('id'); if(empty($id)){ throw new \think\exception\HttpException(406, '找不到相关记录'); } } $detail = (new PagesModel())->getPagesById($id); if(empty($detail)){ throw new \think\exception\HttpException(406, '找不到相关记录'); } //轮播图 if(!empty($detail['banner'])) { $detail['banner_array'] = explode(',',$detail['banner']); } //关键字 $keyword_array = Db::name('PagesKeywords') ->field('i.aid,i.keywords_id,k.title') ->alias('i') ->join('keywords k', 'k.id = i.keywords_id', 'LEFT') ->order('i.create_time asc') ->where(array('i.aid' => $id, 'k.status' => 1)) ->select()->toArray(); $detail['keyword_ids'] = implode(",", array_column($keyword_array, 'keywords_id')); $detail['keyword_names'] = implode(',', array_column($keyword_array, 'title')); $detail['keyword_array'] = $keyword_array; PagesModel::where('id', $id)->inc('read')->update(); View::assign('detail', $detail); return view($detail['template']); } }