<?php
namespace User\Controller;
class ArticleCommentController extends CommController{
public function commentsList(){
$article_id=I("get.article_id");
$this->GetArticleComment($article_id);
$this->display();
}
public function GetArticleComment($article_id){
$Comment=M("articleComment");
$data["article_id"]=$article_id;
$count=$Comment->where($data)->count();
$Page = new \Think\Page($count,10);
$Page->setConfig('theme','%HEADER% %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%');
$Page->setConfig('prev','上一页');
$Page->setConfig('next','下一页');
$show = $Page->show() $result = $Comment->where($data)->limit($Page->firstRow.','.$Page->listRows)->order("article_id desc")->select();
foreach($result as $key=>$value){
$username=$this->getThisArtAuth($value["user_id"]);
$result[$key]["username"]=$username;
}
$this->assign("comment",$result);
$this->assign('page',$show) }
public function getThisArtAuth($user_id){
$User=M("user");
$data["user_id"]=$user_id;
$name=$User->field("user_name")->where($data)->find();
return $name["user_name"];
}
public function deleteComment(){
$data["comm_id"]=I("post.comm_id");
$article_comment=M("article_comment");
$result=$article_comment->where($data)->delete();
if($result){
echo 1;
}else{
echo 0;
}
}
}
?>