誰かが私が間違っているところを見つけるのを手伝ってくれますか?
peter
peter 2017-11-16 22:07:32
0
9
1241

public function read($id)

{

//1すべてのデータを取得

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

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

$viewed=$data['viewed'];

$viewed =1;

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

//2模板赋值

$this ->見る -> 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 ->見る -> 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 ('コメント')->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

人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!