// +---------------------------------------------------------------------- namespace Site\Model; /** * 分类模型 */ class SiteGroupModel extends SiteModel{ protected $_validate = array( array('site_game_id', 'check_game', '该游戏已经存在', self::EXISTS_VALIDATE, 'callback', self::MODEL_BOTH), array('group_code', 'is_numeric', '群号必须是数字', self::EXISTS_VALIDATE, 'function', self::MODEL_BOTH), array('in_num', 'is_numeric', '入驻必须是数字', self::EXISTS_VALIDATE, 'function', self::MODEL_BOTH), array('in_num', [0,10000], '入驻人数错误', self::EXISTS_VALIDATE, 'between', self::MODEL_BOTH), ); protected $_auto = array( array('create_time', NOW_TIME, self::MODEL_INSERT), array('promote_id', PID, self::MODEL_BOTH), ); /** * @param int $promote_id * @return mixed */ public function get_promote_data($promote_id=PID){ $map['promote_id'] = $promote_id; $map['status'] = 1; $data = $this->where($map)->select(); return $data; } /** * 检查游戏是否存在 * @return bool */ public function check_game(){ $map['id'] = ['neq',I('id')]; $map['promote_id'] = PID; $map['site_game_id'] = I('site_game_id'); $data = $this->where($map)->find(); if(empty($data)){ return true; }else{ return false; } } public function saveData($data = "") { $data = I('post.'); $data['game_name'] = get_site_game_name($data['site_game_id']); return parent::saveData($data); // TODO: Change the autogenerated stub } }