Comment.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Community\Lib;
  3. use Dever;
  4. class Comment
  5. {
  6. private function table($type)
  7. {
  8. $table = Dever::db('community/comment')->config['set']['table_name'][$type];
  9. return $table;
  10. }
  11. public function getData($method = 'getAll', $uid, $type = false, $type_id = false)
  12. {
  13. $where['type'] = $type;
  14. $where['type_id'] = $type_id;
  15. $info = Dever::db('community/comment')->$method($where);
  16. $data['info'] = $info;
  17. $data['total'] = Dever::total();
  18. if ($info) {
  19. foreach ($info as $k => $v) {
  20. $data['info'][$k]['uid'] = $v['uid'];
  21. $data['info'][$k]['content'] = $v['content'];
  22. }
  23. }
  24. return $data;
  25. }
  26. # 发表信息
  27. public function submit($uid, $id, $type, $pic, $content, $to_id, $to_uid)
  28. {
  29. $where['uid'] = $uid;
  30. $where['type_id'] = $id;
  31. $where['type'] = $type;
  32. $where['content'] = $content;
  33. $table = 'community/comment';
  34. $info = false;
  35. $data_table = $this->table($type);
  36. if (!$info) {
  37. Dever::db($table)->insert($where);
  38. Dever::score($uid, 'submit_comment', '发布弹幕');
  39. }
  40. return true;
  41. }
  42. }