CommentModel.class.php
1.52 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
<?php
namespace Common\Model;
class CommentModel extends AbstractModel
{
public function __construct()
{
parent::__construct();
}
/**
* 保存评论信息
* User: <362431947@qq.com>
* @param array $data
* @return mixed
* Date: 2018-10-10 Time: 12:04
*/
public function add($data = [])
{
$data['domain'] = md5($_SERVER['HTTP_HOST']);
$data['created'] = $this->microtime();
return $this->_m->insert($data);
}
/**
* 通过留言id获取评论信息
* User: <362431947@qq.com>
* @param int $message_id
* @return array|bool
* Date: 2018-10-11 Time: 12:05
*/
public function getCommentByMsgId($message_id = 0)
{
$params = [];
$wheres = [];
$conds = ['message_id' =>$message_id];
if (!$this->_parse_where($wheres, $params, $conds)) {
return false;
}
$m_person = new PersonModel();
$table_person = $m_person->get_tname();
$sql = "SELECT `comment`,b.name commenter,a.created
FROM __TABLE__ a
LEFT JOIN {$table_person} b ON a.uid = b.person_id
WHERE `message_id` = ? ";
return $this->_m->fetch_array($sql,$params);
}
/**
* 通过留言id删除评论
* User: <362431947@qq.com>
* @param int $message_id
* @return mixed
* Date: 2018-10-11 Time: 12:05
*/
public function del($message_id = 0)
{
return $this->_m->delete($message_id);
}
}