search

Home  >  Q&A  >  body text

Can anyone help me see where I'm going wrong?

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

peterpeter2605 days ago1417

reply all(9)I'll reply

  • 又白又帅又可爱

    又白又帅又可爱2017-11-20 12:23:26

    Project location->application->config.php->Line 20

    'app_debug' => false,

    Change to:

    'app_debug' => true,

    to turn on debugging mode

    reply
    1
  • peter

    solved!

    peter · 2017-11-20 16:19:40
  • 王者風範

    王者風範2017-11-17 11:23:41

    Turn on the debugging mode, and then look at the specific error location

    reply
    0
  • peter

    Can't debug

    peter · 2017-11-17 15:17:42
  • 尹天雄

    尹天雄2017-11-17 11:17:59

    You can debug this with breakpoints. Otherwise, the error message is not obvious and it is difficult for us to judge.

    reply
    0
  • peter

    Can't debug

    peter · 2017-11-17 15:17:52
  • peter

    peter2017-11-17 10:37:14

    Page error! Please try again later~QQ截图20171117103603.png

    reply
    0
  • 天蓬老师

    天蓬老师2017-11-17 00:02:16

    At least you have to give the browser error message, otherwise how can I help you analyze it?

    reply
    0
  • peter

    Page error! Please try again later~

    peter · 2017-11-17 10:34:54
  • Cancelreply