private function update(player $player) { $db = db::obtain(); $data = array('account_id' => player::convert_id($player->get('steamid'))); $data = array_merge($data, $player->get_data_array()); $db->update_pdo(db::real_tablename('users'), $data, array('steamid' => $player->get('steamid'))); }
function getMatchResults($match_id) { if (isset($_GET['match_id'])) { $match_id = intval($_GET['match_id']); } $match_mapper_web = new match_mapper_web($match_id); $match = $match_mapper_web->load(); if (is_null($match)) { die('<p>Match does not exists.</p>'); } $players_mapper_web = new players_mapper_web(); foreach ($match->get_all_slots() as $slot) { if ($slot->get('account_id') != player::ANONYMOUS) { $players_mapper_web->add_id(player::convert_id($slot->get('account_id'))); } } $players = $players_mapper_web->load(); $slots = $match->get_all_slots_divided(); $results = array(); if ($match->get('radiant_win')) { $results['winners'] = getMatchTeamPlayers($slots, $players, 'radiant'); $results['losers'] = getMatchTeamPlayers($slots, $players, 'dire'); } else { $results['winners'] = getMatchTeamPlayers($slots, $players, 'dire'); $results['losers'] = getMatchTeamPlayers($slots, $players, 'radiant'); } return $results; }
/** * @param match $match * @param bool $lazy if true - update all data, if false - only possible updated data */ public function update($match, $lazy = true) { $db = db::obtain(); $slots = $match->get_all_slots(); // update common match info $db->update_pdo(db::real_tablename('matches'), $match->get_data_array(), array('match_id' => $match->get('match_id'))); foreach ($slots as $slot) { // update accounts $db->update_pdo(db::real_tablename('users'), array('account_id' => $slot->get('account_id'), 'steamid' => player::convert_id($slot->get('account_id'))), array('account_id' => $slot->get('account_id'))); // update slots if (!$lazy) { $db->update_pdo(db::real_tablename('slots'), $slot->get_data_array(), array('match_id' => $slot->get('match_id'), 'player_slot' => $slot->get('player_slot'))); } } }