/** * @param int id The liveticker's id. * @return mixed[] An array containing information about the liveticker. */ function get_ticker($id) { global $con; $sql = "SELECT * FROM tickers WHERE id=?"; $stmt = $con->prepare($sql); $stmt->bindParam(1, $id); $stmt->execute(); if ($row = $stmt->fetch()) { return array("duration" => $row["duration"], "finished" => $row["finished"], "id" => $row["id"], "location" => $row["location"], "name" => $row["name"], "running" => $row["running"], "team_a" => $row["team_a"], "team_b" => $row["team_b"], "players" => get_ticker_players($id), "time" => get_current_time($id), "events" => get_ticker_events($id), "goals" => get_goal_count($id)); } return null; }
<?php require_once "../php/main.php"; $id = argreq("id"); $players = get_ticker_players($id); //TODO: distinguish between invalid ticker and empty set if (empty($players) || is_null($players)) { api_error(); } api_done(array("players" => $players));