|
@@ -6,12 +6,21 @@ use Dever;
|
|
|
|
|
|
class Comment
|
|
class Comment
|
|
{
|
|
{
|
|
|
|
+ private function table($type) {
|
|
|
|
+ if ($type == 3) {
|
|
|
|
+ $table = 'act/live_comment';
|
|
|
|
+ } else {
|
|
|
|
+ $table = 'act/comment';
|
|
|
|
+ }
|
|
|
|
+ return $table;
|
|
|
|
+ }
|
|
# 获取评论列表
|
|
# 获取评论列表
|
|
public function get($id, $type)
|
|
public function get($id, $type)
|
|
{
|
|
{
|
|
$where['type'] = $type;
|
|
$where['type'] = $type;
|
|
$where['data_id'] = $id;
|
|
$where['data_id'] = $id;
|
|
- $data = Dever::db('act/comment')->getAll($where);
|
|
|
|
|
|
+ $table = $this->table($type);
|
|
|
|
+ $data = Dever::db($table)->getAll($where);
|
|
|
|
|
|
if ($data) {
|
|
if ($data) {
|
|
foreach ($data as $k => $v) {
|
|
foreach ($data as $k => $v) {
|
|
@@ -30,9 +39,10 @@ class Comment
|
|
$where['data_id'] = $id;
|
|
$where['data_id'] = $id;
|
|
$where['type'] = $type;
|
|
$where['type'] = $type;
|
|
$where['content'] = $content;
|
|
$where['content'] = $content;
|
|
- $info = Dever::db('act/comment')->one($where);
|
|
|
|
|
|
+ $table = $this->table($type);
|
|
|
|
+ $info = Dever::db($table)->one($where);
|
|
if (!$info) {
|
|
if (!$info) {
|
|
- Dever::db('act/comment')->insert($where);
|
|
|
|
|
|
+ Dever::db($table)->insert($where);
|
|
}
|
|
}
|
|
|
|
|
|
# 更新评论数
|
|
# 更新评论数
|
|
@@ -40,7 +50,7 @@ class Comment
|
|
$where['data_id'] = $id;
|
|
$where['data_id'] = $id;
|
|
$where['type'] = $type;
|
|
$where['type'] = $type;
|
|
$where['state'] = 1;
|
|
$where['state'] = 1;
|
|
- $total = Dever::db('act/comment')->total($where);
|
|
|
|
|
|
+ $total = Dever::db($table)->total($where);
|
|
$table = Dever::config('base')->type_table[$type];
|
|
$table = Dever::config('base')->type_table[$type];
|
|
Dever::db($table)->update(array('where_id' => $id, 'num_comment' => $total));
|
|
Dever::db($table)->update(array('where_id' => $id, 'num_comment' => $total));
|
|
|
|
|