CommentModel.class.php
1.85 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
<?php
namespace Common\Model;
class CommentModel extends AbstractModel
{
public function __construct()
{
parent::__construct();
}
public function addOne($data)
{
return $this->_m->insert($data);
}
/**
* 保存评论信息
* @author <362431947@qq.com>
* @date 2018-10-10
*/
public function add($data = [])
{
$data['domain'] = md5($_SERVER['HTTP_HOST']);
$data['created'] = $this->microtime();
print_r($data);
return $this->_m->insert($data);
// $comment_id = $this->_m->insert($data);
// $msg_comment = [
// 'message_id' => intval($data['message_id']),
// 'comment_id' => $comment_id,
// 'domain' => md5($_SERVER['HTTP_HOST']),
// 'created' => $this->microtime(),
// ];
// $m_msg_comment = new MsgCommentModel();
//
// $id = $m_msg_comment->add($msg_comment);
//
// if($comment_id && $id){
// $this->_m->commit();
// $result = true;
// }
// else{
// $this->_m->rollback();
// $result = false;
// }
// return $result;
}
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
FROM __TABLE a
LEFT JOIN {$table_person} b ON a.uid = b.person_id
WHERE `message` = ? ";
return $this->_m->fetch_array($sql,$params);
}
public function del($message_id = 0)
{
return $this->_m->delete($message_id);
}
}