php 讨论版无限极回复,TP5 无限极评论回复

TP5 无限极评论回复

TP5 无限极评论回复

首先说一下这个数据库的设计:

b4dffd85a8e1cd459895de4f96b64da1.png

然后是他的自调用控制器当中:

protected function list($pid = 0,$id,&$result=array()){

$model = new Comment;

$arr =$model->where("pid",$pid)->where()->select();

if(empty($arr)){

return array();

}

foreach ($arr as $cm) {

$thisArr=&$result[];

$cm["children"] = $this->list($cm["id"],$id,$thisArr);

$thisArr = $cm;

}

return $result;

}

public function get_news_comment(){

$id = $this->request->param("news_id");

if (!$id) {

$this->error("参数错误");

}

// $return_data=Db::name('comment')->select();

$model = new Comment;

// $return_data=$model->list($id);

$return_data['num'] = $model->count(); //获取评论总数

$return_data['list']=$this->list();//获取评论列表

if ($return_data) {

$this->success("返回成功", $return_data);

} else {

$this->success("没有信息");

}

}

TP5 无限极评论回复相关教程

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值