GameQqModel.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * GamePlayModel.php UTF-8
  4. * WWW
  5. *
  6. * @date : 2018/7/13 20:18
  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 GameQqModel extends CommonModel {
  15. protected $name = 'game_qq';
  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. /**
  35. * 关联game表
  36. *
  37. * @return mixed
  38. */
  39. public function qq() {
  40. return $this->belongsTo('huo\model\conf\QqConfModel', 'qq_id')->field('id,qq,idkey,ios_key,and_key');
  41. }
  42. /**
  43. * 更新信息
  44. *
  45. * @param $game_data
  46. * @param $id
  47. *
  48. * @return bool
  49. */
  50. public function updateGame($game_data, $id) {
  51. $_map['id'] = $id;
  52. $_data = $game_data;
  53. $_rs = self::update($_data, $_map, true);
  54. if (false == $_rs) {
  55. return false;
  56. }
  57. return true;
  58. }
  59. /**
  60. * 添加一条记录
  61. *
  62. * @param $data
  63. *
  64. * @return bool|mixed
  65. */
  66. public function addGame($data) {
  67. if (empty($data)) {
  68. return false;
  69. }
  70. $_obj = self::create($data, true);
  71. if (false == $_obj) {
  72. return false;
  73. }
  74. return true;
  75. }
  76. }