TP框架 上一页,下一页功能实现

        $info=\app\common\model\Article::where('faxi',1)->limit(6)->select();
// 取到  
        $ids=\app\common\model\Article::where('faxi',1)->column('id');
        $idj=[];
        foreach ($ids as $v){
            $idj[]=$v;
        }
        $fid=reset($idj);
        $eid=end($idj);
        if($id==$fid){
            $last=\app\common\model\Article::where('id','=',$eid)->find();
        }else{
            $last=\app\common\model\Article::where('id','<',$id)->order('id','desc')->limit(1)->find();
        }
        if($id==$eid){
            $next=\app\common\model\Article::where('id','=',$fid)->find();
        }else{
            $next=\app\common\model\Article::where('id','>',$id)->order('id','asc')->limit(1)->find();
        }
        $list=\app\common\model\Article::where('id',$id)->find();
        return view('article_show',compact('list','last','next','info'));

你可能感兴趣的:(TP框架 上一页,下一页功能实现)