* @version : HUOSDK 8.0 */ namespace huo\model\game; use huo\model\common\CommonModel; class GameHelpModel extends CommonModel { protected $name = 'game_help'; // 开启自动写入时间戳字段 protected $autoWriteTimestamp = true; /** * 基础查询 * * @param $query */ protected function base($query) { $query->where('delete_time', 0)->where('is_delete', 2); } /** * 关联game表 * * @return mixed */ public function game() { return $this->belongsTo('huo\model\game\GameModel', 'app_id')->field('id,name game_name'); } public function updateGmh($gmh_data, $game_id) { $_map['app_id'] = $game_id; $_data = $gmh_data; $_data['update_time'] = time(); $_rs = self::update($_data, $_map, true); if (false == $_rs) { return false; } else { return true; } } /** * 获取单条记录 * * @param int $id * * @param bool $base * * @return array|false * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getInfoByAppId($id, $base = true) { $_map['app_id'] = $id; $_info = $this->useGlobalScope($base)->where($_map)->find(); if (false === $_info) { return false; } if (is_object($_info)) { return $_info->toArray(); } else { return $_info; } } /** * 添加一条记录 * * @param $data * * @return bool|mixed */ public function addGmh($data) { if (empty($data)) { return false; } $_obj = self::create($data, true); if (false == $_obj) { return false; } return true; } }