public static function leagueExists($leagueid) { $leagueid = (int) $leagueid; $db = Db::obtain(); $r = $db->queryFirstPDO('SELECT leagueid FROM ' . Db::realTablename('leagues') . ' WHERE leagueid = ?', array($leagueid)); return (bool) $r; }
/** * @param Item[] $data list of items */ public function save(array $data) { $db = Db::obtain(); $dataToInsert = array(); foreach ($data as $item) { array_push($dataToInsert, $item->getDataArray()); } $db->insertManyPDO(Db::realTablename('items'), array('id', 'name', 'cost', 'secret_shop', 'side_shop', 'recipe', 'localized_name'), $dataToInsert, true); }
/** * @param string $id * @return bool */ public static function playerExists($id = null) { if (null === $id) { return false; } $db = Db::obtain(); $result = $db->queryFirstPDO('SELECT steamid FROM ' . Db::realTablename('users') . ' WHERE steamid = ?', array($id)); return $result['steamid'] === (string) $id; }
public static function setUpBeforeClass() { $db = Db::obtain(); $db->exec('DELETE FROM ' . Db::realTablename('league_prize_pools') . ''); $leaguesMapperWeb = new LeaguesMapperWeb(); $leagues = $leaguesMapperWeb->load(); $leaguesMapperDb = new LeaguesMapperDb(); $leaguesMapperDb->save($leagues[600]); }
public function save() { $leagueid = $this->getLeagueId(); $prizePool = $this->getPrizePool(); if (null === $prizePool || null === $leagueid) { return; } $db = Db::obtain(); $data = array('league_id' => $leagueid, 'prize_pool' => $prizePool); $db->insertPDO(Db::realTablename('league_prize_pools'), $data); echo $db->getError(); }
public function load() { $db = Db::obtain(); $players = array(); $ids = $this->getIdsString(); if (count($this->_ids) === 0) { return array(); } $result = $db->fetchArrayPDO('SELECT * FROM ' . Db::realTablename('users') . ' WHERE steamid IN (' . $ids . ')', array()); foreach ($result as $r) { $player = new Player(); $player->setArray((array) $r); $players[$player->get('steamid')] = $player; } return $players; }
/** * Get matches ids with provided heroid or account_id (query for "slots" table) * @return array */ private function _getMatchesIdsFromSlots() { $db = Db::obtain(); $forSlots = 'SELECT match_id ' . Db::realTablename('FROM slots') . ''; $whereForSlots = ''; $dataForSlots = array(); if (null !== $this->getHeroId()) { $whereForSlots .= 'heroid = ? AND '; array_push($dataForSlots, $this->getHeroId()); } if (null !== $this->getAccountId()) { $whereForSlots .= 'account_id = ? AND '; array_push($dataForSlots, $this->getAccountId()); } if (trim($whereForSlots) !== '') { $forSlots .= ' WHERE ' . substr($whereForSlots, 0, strlen($whereForSlots) - 4); } $matchesIds = $db->fetchArrayPDO($forSlots, $dataForSlots); $ret = array(); foreach ($matchesIds as $val) { array_push($ret, $val['match_id']); } return $ret; }
/** * Delete match data from db * * @param int $matchId * @return bool */ public static function matchExists($matchId) { $matchId = (int) $matchId; $db = Db::obtain(); $r = $db->queryFirstPDO('SELECT match_id FROM ' . Db::realTablename('matches') . ' WHERE match_id = ?', array($matchId)); return (bool) $r; }