Manage.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Act\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. //{source_id} > 0 ? ("{name}" ? "{name}" : Dever::load("sad/supply-one#name", {source_id})) : "{name}"
  7. public function load($source_table, $id, $mid = false)
  8. {
  9. $table = Dever::config('base')->type_table[$source_table];
  10. $data = Dever::db($table)->one($id);
  11. if ($data && isset($data['name']) && $data['name']) {
  12. return $data['name'] . '('.$mid.')';
  13. }
  14. if ($data && isset($data['content']) && $data['content']) {
  15. return $data['content'] . '('.$mid.')';
  16. }
  17. return '未知' . '('.$mid.')';
  18. }
  19. # 根据data_id获取data_name
  20. public function getName_api()
  21. {
  22. $data = Dever::db('act/comment')->state();
  23. if ($data) {
  24. foreach ($data as $k => $v) {
  25. $name = $this->load($v['type'], $v['data_id']);
  26. if ($name && $name != $v['data_name']) {
  27. Dever::db('act/comment')->update(array('where_id' => $v['id'], 'data_name' => $name));
  28. }
  29. }
  30. }
  31. $data = Dever::db('act/live_comment')->state();
  32. if ($data) {
  33. foreach ($data as $k => $v) {
  34. $name = $this->load($v['type'], $v['data_id']);
  35. if ($name && $name != $v['data_name']) {
  36. Dever::db('act/live_comment')->update(array('where_id' => $v['id'], 'data_name' => $name));
  37. }
  38. }
  39. }
  40. }
  41. }