Example #1
0
 public function getUserComment($mer_id)
 {
     $cond = '1=1 and comment_status=1';
     if ($mer_id) {
         $cond .= " and model_id={$mer_id}";
     }
     $pages = new Pagination(['defaultPageSize' => 1, 'totalCount' => $this->find()->where($cond)->count()]);
     $comment = Comment::find()->where($cond)->offset($pages->offset)->limit($pages->limit)->orderby('comment_addtime desc')->asArray()->all();
     $comment['pages'] = $pages;
     return $comment;
 }
 public function actionComment()
 {
     $user_id = 1;
     $comment = new Comment();
     $pagination = new Pagination(['defaultPageSize' => 1, 'totalCount' => $comment->find()->where(['and', ['model_id' => $user_id, 'comment_type' => 1, 'comment_status' => 1]])->count()]);
     $commentlist = $comment->getComment($user_id, $pagination);
     return $this->render('comment', ['comment' => $commentlist, 'pagination' => $pagination]);
 }