谁能帮我看看哪里错了
peter
peter 2017-11-16 22:07:32
[PHP讨论组]

public function read($id)

    {

    //1获取所有的数据

        $this -> view -> assign('aid', $id);

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

        $viewed=$data['viewed'];

        $viewed+=1;

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

        //2模板赋值

        $this -> view -> assign('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 -> view -> assign('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;//初始为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]['username']=$v['username'];

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

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

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

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

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

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

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

            $i++;

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

        }

        return $commentList;

        //dump($commentList);

    }

QQ截图20171116220535.png

peter
peter

peter

全部回复(5)
又白又帅又可爱

项目位置->application->config.php->第20行

'app_debug'              => false,

改为:

'app_debug'              => true,

即可打开调试模式

  • 回复 已解决!
    peter 作者 2017-11-20 16:19:40
王者風範

把调试模式打开呀,然后看具体的报错位置

  • 回复 不会调试
    peter 作者 2017-11-17 15:17:42
尹天雄

这个你可以断点调试下。不然错误提示不明显,我们不好判断。

  • 回复 不会调试
    peter 作者 2017-11-17 15:17:52
peter

页面错误!请稍后再试~QQ截图20171117103603.png

天蓬老师

至少你要给出浏览器的报错信息,否则怎么帮你分析?

  • 回复 页面错误!请稍后再试~
    peter 作者 2017-11-17 10:34:54
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号