123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- /**
- * GameHelpModel.php UTF-8
- * WWW
- *
- * @date : 2018/7/12 17:53
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @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;
- }
- }
|