Dao.php
4.32 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
* User: elkan
* Date: 14-7-29
* Time: 下午3:49
* To change this template use File | Settings | File Templates.
*/
use YHMComment\SqlMap\Comment;
class YHMComment_Models_Comment_Dao extends YHMComment_Dao {
private $_tag = 'comment_';
public function __construct() {
$this->router = 'comment.yhm_comments';
}
/**
* 通过ID获取一条评论
* @param integer $id
*/
function getOneById($id) {
return $this->dao()->cache(false)->fetchRow(Comment\Comment::SELECT_ONE_BY_ID, array('id' => $id));
}
/**
* 获取商品评论总数
* @param int $product_skc
* @return int
*/
function getCountBySkc($store_id, $product_skc) {
return $this->dao()->tag($this->_tag . $store_id)->key('getCountBySkc_' . $product_skc)
->fetchOne(Comment\Comment::COUNT_LIST_BYSKC, array("product_skc" => $product_skc));
}
/**
* 获取商品评论列表
* @param integer $store_id
* @param integer $product_skc
* @param integer $offset
* @param integer $num
* @return Ambigous <multitype:, Mixed, multitype:unknown >
*/
function getListBySkc($store_id, $product_skc, $offset, $num) {
return $this->dao()->tag($this->_tag . $store_id)->key('getListBySkc_' . $product_skc . '_' . $offset . '_' . $num)
->fetchAssoc(Comment\Comment::SELECT_COMMENT_BYSKC, array("product_skc" => $product_skc, "offset" => $offset, "num" => $num));
}
/**
* 获取评论内容
* @param int $id
* @return string
*/
function getContentById($store_id, $id) {
return $this->dao()->tag($this->_tag . $store_id)->key('getContentById_' . $id)
->fetchRow(Comment\Comment::SELECT_COMMENT_CONTENT_BYID, array("id" => $id));
}
/**
* 添加评论
* @param int $store_id
* @param int $product_skc
* @param string $content
* @param int $star
* @param int $uid
* @return int
*/
function add($uid, $order_code, $store_id, $product_skc, $star) {
return $this->dao()->tag($this->_tag . $store_id)->insert(Comment\Comment::INSERT_COMMENT, array(
"uid" => $uid,
"order_code" => $order_code,
"store_id" => $store_id,
"product_skc" => $product_skc,
"star" => $star
))->lastInsertId();
}
/**
* 添加评论内容
* @param int $id
* @param string $content
* @return type
*/
function addContent($store_id, $id, $content) {
return $this->dao()->tag($this->_tag . $store_id)->insert(Comment\Comment::INSERT_COMMENT_CONTENT, array(
"id" => $id,
"content" => $content
))->status();
}
/**
* 取出店铺评论总数
* @param int $product_id
* @return type
*/
function getCountByStoreId($store_id) {
return $this->dao()->tag($this->_tag . $store_id)->key('getCountByStoreId')
->fetchOne(Comment\Comment::SELECT_COUNT_BY_STORE_ID, array("store_id" => $store_id));
}
/**
* 取出店铺总得分
* @param int $store_id
* @return type
*/
function getSumStarByStoreId($store_id) {
return $this->dao()->tag($this->_tag . $store_id)->key('getSumStarByStoreId')
->fetchOne(Comment\Comment::SELECT_SUMSTAR_BY_STORE_ID, array("store_id" => $store_id));
}
/**
* 删除评论信息
* @param int $id
* @param int $uid
* @return type
*/
function del($store_id, $id) {
return $this->dao()->tag($this->_tag . $store_id)->delete(Comment\Comment::DELETE_COMMENT_BYID, array("id" => $id))->status();
}
/**
* 删除评论内容
* @param int $id
* @return type
*/
function delContent($store_id, $id) {
return $this->dao()->tag($this->_tag . $store_id)->delete(Comment\Comment::DELETE_COMMENT_CONTENT_BYID, ARRAY("id" => $id))->status();
}
/**
* 查看该订单是否评价
* @param type $order_code
*/
function checkUserCommentByOrderCode($order_code, $uid) {
return $this->dao()->cache(false)->fetchRow(Comment\Comment::SELECT_COMMENT_BY_ORDER_CODE, array('order_code' => $order_code, 'uid' => $uid));
}
}