ArticleComment.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. namespace We7\Table\Site;
  7. class ArticleComment extends \We7Table {
  8. protected $tableName = 'site_article_comment';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'uniacid',
  12. 'articleid',
  13. 'parentid',
  14. 'uid',
  15. 'openid',
  16. 'content',
  17. 'is_read',
  18. 'iscomment',
  19. 'createtime',
  20. );
  21. protected $default = array(
  22. 'uniacid' => '',
  23. 'articleid' => '',
  24. 'parentid' => '',
  25. 'uid' => '',
  26. 'openid' => '',
  27. 'content' => '',
  28. 'is_read' => 1,
  29. 'iscomment' => 1,
  30. 'createtime' => '',
  31. );
  32. public function getAllByCurrentUniacid() {
  33. global $_W;
  34. return $this->where('uniacid', $_W['uniacid'])->getall();
  35. }
  36. public function addComment($comment) {
  37. if (!empty($comment['parentid'])) {
  38. $this->where('id', $comment['parentid'])->fill('iscomment', ARTICLE_COMMENT)->save();
  39. }
  40. $comment['createtime'] = TIMESTAMP;
  41. return $this->fill($comment)->save();
  42. }
  43. public function srticleCommentUnread($article_ids) {
  44. global $_W;
  45. return $this->query->select('articleid, count(*) as count')
  46. ->where('uniacid', $_W['uniacid'])
  47. ->where('articleid', $article_ids)
  48. ->where('is_read', ARTICLE_COMMENT_NOREAD)
  49. ->groupby('articleid')
  50. ->getall('articleid');
  51. }
  52. }