当前位置: 首页>>代码示例>>PHP>>正文


PHP CommentModel::addComment方法代码示例

本文整理汇总了PHP中CommentModel::addComment方法的典型用法代码示例。如果您正苦于以下问题:PHP CommentModel::addComment方法的具体用法?PHP CommentModel::addComment怎么用?PHP CommentModel::addComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommentModel的用法示例。


在下文中一共展示了CommentModel::addComment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: AddCommentAction

 public function AddCommentAction()
 {
     $request = Project::getRequest();
     $item_name = $request->item_name;
     $comment_model = new CommentModel($item_name . '_comment', $item_name . '_id', 0);
     switch ($item_name) {
         case 'article':
             $item_model = new ArticleModel();
             break;
         case 'questions':
             $item_model = new QuestionModel();
             break;
         case 'photo':
             $item_model = new PhotoModel();
             break;
         case 'bookmarks':
             $item_model = new BookmarksModel();
             break;
         case 'social':
             $item_model = new SocialModel();
             break;
         case 'blog':
             $item_model = new BlogModel('blog_post');
             break;
     }
     $item_model->load($request->element_id);
     if ($item_model->id > 0 && $request->add_comment) {
         $comment_model->addComment(Project::getUser()->getDbUser()->id, $request->avatar_id, 0, $request->element_id, $request->comment, $request->mood_id, $request->mood_text, 0);
         $item_model->comments++;
         $item_model->save();
     }
     Project::getResponse()->redirect($request->createUrl($request->cur_controller, $request->cur_action, array($request->element_id)));
 }
开发者ID:amanai,项目名称:next24,代码行数:33,代码来源:BaseCommentController.php

示例2: comment

 public function comment()
 {
     if (!empty($_POST)) {
         $_POST['userId'] = $_SESSION['qq']['userId'];
         $arr = $_POST;
         $comment = new CommentModel();
         $row = $comment->addComment($_POST);
         if ($row) {
             $user = new UserModel();
             $arr['addTime'] = data('Y-m-d H:i:s');
             $user = $user->getUser($_POST['userId']);
             $arr['face'] = $user['face'];
             $arr['userName'] = $user['userName'];
             echo json_encode($arr);
         } else {
             exit('发表失败');
         }
     }
 }
开发者ID:Jnnock,项目名称:myyyk,代码行数:19,代码来源:ArticleCtrl.class.php

示例3: postComment

 /**
  * 添加评论
  * post: blog_id, content
  */
 public function postComment()
 {
     if (!$this->hasLoginCheck()) {
         return;
     }
     $blog_id = $_POST['blog_id'];
     $content = $_POST['content'];
     $user_id = session('user_id');
     $commentModel = new CommentModel();
     $commentModel->addComment($blog_id, $content);
     $userModel = M('user');
     $comment_user = $userModel->find($user_id);
     $comment = array('user_name' => $comment_user['name'], 'user_id' => $comment_user['id'], 'user_homepage' => $this->conf['APP_ROOT'] . 'Home/userblog/user_id/' . $comment_user['id'], 'user_head_picpath' => $comment_user['head_pic_path'], 'user_comment' => $content);
     $li_html = $this->tpl->getSingleCommentLi($comment, $commentModel->getSomeBlogCommentCount($blog_id));
     echo json_encode(array('status' => 'true', 'li_html' => $li_html));
 }
开发者ID:nyankosama,项目名称:OnlyMyBlog,代码行数:20,代码来源:PostBlogAction.class.php

示例4: addalbumComment

 public function addalbumComment()
 {
     if (!$_SESSION['qq']) {
         $result['code'] = '021';
         $result['message'] = '未登录,请登录账号!';
     } else {
         //实例化model
         $commentModel = new CommentModel();
         $albumModel = new AlbumModel();
         $albumId = $_GET['albumId'];
         $content = $_GET['comment'];
         //根据相册id查询相册信息
         $albumInfo = $albumModel->getAlbumById($albumId);
         $data = array('userId' => $_SESSION['qq']['userId'], 'albumId' => $albumId, 'content' => $content, 'adminId' => $albumInfo['adminId']);
         $commentId = $commentModel->addComment($data);
         if ($commentId) {
             $commentInfo = $commentModel->getCommentById($commentId);
             $result['code'] = '0';
             $result['message'] = '恭喜,评论成功!';
             $result['info'] = $commentInfo;
         } else {
             $result['code'] = '022';
             $result['message'] = '抱歉,评论失败!';
         }
     }
     echo json_encode($result);
     exit;
 }
开发者ID:Jnnock,项目名称:myyyk,代码行数:28,代码来源:AlbumCtrl.class.php

示例5: testAddCommentFail

 public function testAddCommentFail()
 {
     $userTable = new UserModel();
     $moodTable = new MoodListModel();
     $commentTable = new CommentModel();
     $findUser['phone'] = '333333';
     $user = $userTable->where($findUser)->find();
     $findMood['content'] = '我是王五';
     $ret = $commentTable->addComment($user['id'], $mood['id'], '');
     $this->assertTrue($ret === false && $commentTable->getError() == '内容不能为空');
 }
开发者ID:chen8840,项目名称:LMJ-s-project,代码行数:11,代码来源:CommentModelTest.php

示例6: addAlbumComment

 public function addAlbumComment()
 {
     if (!$_SESSION['qq']) {
         $result['code'] = "021";
         $result['message'] = "未登录,请登录账号!";
     } else {
         $_POST['content'] = Data::filter($_POST['content'], 9);
         $_POST['albumId'] = Data::get($_POST['albumId'], Data::Int);
         $_POST['adminId'] = Data::get($_POST['adminId'], Data::Int);
         $_POST['userId'] = Data::get($_POST['userId'], Data::Int);
         $comment = new CommentModel();
         $row = $comment->addComment($_POST);
         if ($row) {
             $comments = $comment->getCommentById($row);
             $result['info'] = $comments;
             $result['code'] = "0";
             $result['message'] = "恭喜,评论成功!";
         } else {
             $result['code'] = "022";
             $result['message'] = "评论失败";
         }
     }
     echo json_encode($result);
     exit;
 }
开发者ID:Jnnock,项目名称:myyyk,代码行数:25,代码来源:IndexCtrl.class.php


注:本文中的CommentModel::addComment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。