tp5文章浏览量添加,开发浏览量
每次刷新都会增加+1,数据库表字段‘pv’;
tp5插入浏览量语句:
//新闻详情 public function detail() { $id = input('id'); //插入浏览量 Db::table('wz_news_article')->where('id',$id)->setInc('pv'); }
新闻详情全部代码::::
//新闻详情 public function detail() { $id = input('id'); $InfoDetail = Db::table('wz_news_article')->where('id',$id)->find(); //插入浏览量 Db::table('wz_news_article')->where('id',$id)->setInc('pv'); //上下页 $befor=Db::table('wz_news_article')->where('id>'.$id)->order('id asc')->limit('1')->find(); $after=Db::table('wz_news_article')->where('id<'.$id)->order('id desc')->limit('1')->find(); $this->assign(['data'=>$InfoDetail,'befor'=>$befor,'after'=>$after]); return $this->fetch(); }