You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB
PHP

<?php
namespace Base\Repository;
use Base\Tool\Registry;
class GameRepository
{
public function getBaseGames($isRefresh = false)
{
$baseGames = Registry::get('base_games');
if ($isRefresh || is_null($baseGames)) {
$baseGames = M('base_game', 'tab_')->where('1=1')->select();
Registry::set('base_games', $baseGames);
}
return $baseGames;
}
public function getBaseGameByGameId($gameId)
{
return M('base_game', 'tab_')->where('android_game_id=' . $gameId . ' or ios_game_id=' . $gameId)->find();
}
public function getChoiceGames(array $visibleGameIds = null, $fields = ['id', 'game_name'])
{
$map = [];
$map['_string'] = '1=1';
if (is_null($visibleGameIds)) {
} elseif (count($visibleGameIds) > 0) {
$map['_string'] = ' and id in (' . implode(',', $visibleGameIds) . ')';
} else {
$map['_string'] = ' and 1=0';
}
return M('game', 'tab_')->field($fields)->where($map)->select();
}
public function getServersByGameId($gameId, $fields = ['id', 'server_name', 'server_id'])
{
$map = [];
$map['game_id'] = $gameId;
return M('server', 'tab_')
->where($map)
->order('server_id asc')
->select();
}
}