GameHelpModel.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * GameHelpModel.php UTF-8
  4. * WWW
  5. *
  6. * @date : 2018/7/12 17:53
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\model\game;
  13. use huo\model\common\CommonModel;
  14. class GameHelpModel extends CommonModel {
  15. protected $name = 'game_help';
  16. // 开启自动写入时间戳字段
  17. protected $autoWriteTimestamp = true;
  18. /**
  19. * 基础查询
  20. *
  21. * @param $query
  22. */
  23. protected function base($query) {
  24. $query->where('delete_time', 0)->where('is_delete', 2);
  25. }
  26. /**
  27. * 关联game表
  28. *
  29. * @return mixed
  30. */
  31. public function game() {
  32. return $this->belongsTo('huo\model\game\GameModel', 'app_id')->field('id,name game_name');
  33. }
  34. public function updateGmh($gmh_data, $game_id) {
  35. $_map['app_id'] = $game_id;
  36. $_data = $gmh_data;
  37. $_data['update_time'] = time();
  38. $_rs = self::update($_data, $_map, true);
  39. if (false == $_rs) {
  40. return false;
  41. } else {
  42. return true;
  43. }
  44. }
  45. /**
  46. * 获取单条记录
  47. *
  48. * @param int $id
  49. *
  50. * @param bool $base
  51. *
  52. * @return array|false
  53. * @throws \think\Exception
  54. * @throws \think\db\exception\DataNotFoundException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. * @throws \think\exception\DbException
  57. */
  58. public function getInfoByAppId($id, $base = true) {
  59. $_map['app_id'] = $id;
  60. $_info = $this->useGlobalScope($base)->where($_map)->find();
  61. if (false === $_info) {
  62. return false;
  63. }
  64. if (is_object($_info)) {
  65. return $_info->toArray();
  66. } else {
  67. return $_info;
  68. }
  69. }
  70. /**
  71. * 添加一条记录
  72. *
  73. * @param $data
  74. *
  75. * @return bool|mixed
  76. */
  77. public function addGmh($data) {
  78. if (empty($data)) {
  79. return false;
  80. }
  81. $_obj = self::create($data, true);
  82. if (false == $_obj) {
  83. return false;
  84. }
  85. return true;
  86. }
  87. }