Exemple #1
0
function getAllGames()
{
    $sql = "select * FROM games";
    $regions = getAllRegions();
    $teams = getTeamsArray();
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
        $stmt->execute();
        $games = $stmt->fetchAll(PDO::FETCH_OBJ);
        foreach ($games as $game) {
            //Récup infos teams
            $game->region = $regions[$game->region]->name;
            $game->blue = $teams[$game->blue]->name;
            $game->red = $teams[$game->red]->name;
            $game->winner = $game->winner == 1 ? $game->blue : $game->red;
            //Récup compos
            $game->blue_compo = getCompo($game->blue_compo);
            $game->red_compo = getCompo($game->red_compo);
            //Récup bans
            $game->blue_bans = getBans($game->blue_bans);
            $game->red_bans = getBans($game->red_bans);
        }
        return $games;
    } catch (PDOException $e) {
        return null;
    }
}
Exemple #2
0
function getAllTeams()
{
    $sql = "select * FROM teams";
    $regions = getAllRegions();
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
        $stmt->execute();
        $teams = $stmt->fetchAll(PDO::FETCH_OBJ);
        foreach ($teams as $team) {
            $team->region = $regions[$team->region]->name;
        }
        return $teams;
    } catch (PDOException $e) {
        return null;
    }
}