Example #1
0
    $response["SoccerMatches"] = array();
    // looping through result and preparing soccer matches array
    while ($soccerMatch = $result->fetch_assoc()) {
        $soccerMatch["IsPracticeMatch"] = (bool) $soccerMatch["IsPracticeMatch"];
        array_push($response["SoccerMatches"], $soccerMatch);
    }
    echoRespnse(200, $response);
});
$app->get('/soccer-matches/:id/', function ($soccerMatchID) {
    global $user_id;
    $response = array();
    $response["Error"] = false;
    $response["SoccerMatch"] = array();
    $db = new DbHandler();
    $matchResult = $db->getSoccerMatchByID($user_id, $soccerMatchID);
    $lineupResult = $db->getSoccerMatchLineup($user_id, $soccerMatchID);
    $eventsResult = $db->getSoccerMatchEvents($user_id, $soccerMatchID);
    $response["Error"] = false;
    $soccerMatch = $matchResult->fetch_assoc();
    $lineup = array();
    while ($x = $lineupResult->fetch_assoc()) {
        array_push($lineup, $x);
    }
    $events = array();
    while ($x = $eventsResult->fetch_assoc()) {
        $x["IsPrimaryEvent"] = (bool) $x["IsPrimaryEvent"];
        array_push($events, $x);
    }
    $soccerMatch["Lineup"] = $lineup;
    $soccerMatch["Events"] = $events;
    $response["SoccerMatch"] = $soccerMatch;