Blame view

framework/table/sitearticlecomment.table.php 1.37 KB
4d84a934   曹明   初始代码提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
 * [WeEngine System] Copyright (c) 2014 WE7.CC
 * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
 */

defined('IN_IA') or exit('Access Denied');
class SitearticlecommentTable extends We7Table {
	protected $tableName = 'site_article_comment';
	protected $primaryKey = 'id';
	protected $field = array('id', 'uniacid', 'articleid', 'parentid', 'uid', 'openid', 'content', 'is_read', 'iscomment', 'createtime');

	public function articleCommentList() {
		global $_W;
		return $this->query->from($this->tableName)->where('uniacid', $_W['uniacid'])->getall();
	}


	public function articleCommentOrder($order = 'DESC') {
		$order = !empty($order) ? $order : 'DESC';
		return $this->query->orderby('id', $order);
	}

	public function articleCommentAdd($comment) {
		if (!empty($comment['parentid'])) {
			table('sitearticlecomment')->where('id', $comment['parentid'])->fill('iscomment', ARTICLE_COMMENT)->save();
		}
		$comment['createtime'] = TIMESTAMP;
		table('sitearticlecomment')->fill($comment)->save();
		return true;
	}

	public function srticleCommentUnread($articleIds) {
		global $_W;
		return $this->query->from($this->tableName)->select('articleid, count(*) as count')->where('uniacid', $_W['uniacid'])->where('articleid', $articleIds)->where('is_read', ARTICLE_COMMENT_NOREAD)->groupby('articleid')->getall('articleid');
	}
}