谁能帮我看看哪里错了
peter
peter 2017-11-16 22:07:32
0
9
1242

public function read($id)

    {

    //1获取所有的数据

        $this ->查看->分配('aid', $id);

        $data=ArticleModel::get($id);

        $viewed=$data['viewed'];

        $viewed+=1;

        $data->isUpdate(true)->save(['viewed' => $viewed]);

        //2模板属性

        $this ->查看->分配('data', $data);


##        //$comment=Comment::order(['id' => 'desc'])->; where(['aid'=>$id,'status'=>1])->paginate(5);

        $comment = $this ->; CommentListAll($aid=$id,$pid=0,$commentList=array(),$spac=0,$pauthor=NULL);

        //$comment=Comment::all();

        dump($comment);

        $this ->查看->分配('commentlist', $comment);

        return $this-> view ->fetch('detail');


#        

    }


#      //评论列表

    function CommentListAll($aid=0,$pid=0,&$commentList=array(),$spac=0,$pauthor=NULL)

    {

        static $i=0;

        $spac=$spac+1;//最终为一级评论

        $pauthor=$pauthor;

        $List= db('comment')->order(['id' => 'desc'])->where(['aid'=>$aid,'status'=>1])->; select();

        //$List=Comment::all(['pid'=>$pid,'status'=>1]);

        //dump( $List);

        foreach($List as $k=>$v){

            $commentList[$i]['level']=$spac;//评论体系

            $commentList[$i]['用户名']=$v['用户名'];

            $commentList[$i]['id']=$v['id'] ;

            $commentList[$i]['aid']=$v['aid'];

            $commentList[$i]['uid']=$v['uid '];

            $commentList[$i]['pid']=$v['pid'];//此条评论的父id

            $commentList[$i][ '内容']=$v['内容'];

            $commentList[$i]['时间']=$v['时间'];

            $commentList[$i]['pauthor']=$pauthor;

            $i++;

              $this -> CommentListAll($v['aid'],$v['id'],$commentList,$spac,$v['用户名']);

        }

        return $commentList;

        //dump($commentList);

    }

QQ截图20171116220535.png

peter
peter

peter

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!