public static function get_fixture_id($round, $date, $team) { $query = "SELECT id FROM fixture WHERE gameweek = %d AND kickoff_time = %s AND"; $team = explode(" ", $team); $team = explode("(", $team[0]); $team_id = Club::get_club_id_by_short($team[0]); if (strpos($team[1], "A") === false) { // playing at home $query = $query . " away_team = %d"; } else { // playing away $query = $query . " home_team = %d"; } $query = $query . " LIMIT 1"; $result = DB::query($query, $round, Fixture::convert_kickoff_time($date), $team_id); if (sizeof($result) == 1) { return (int) $result[0]['id']; } return false; }
function set_opponent($opponent, $team) { $data = explode(" ", $opponent); $opp = explode("(", $data[0]); if (strpos($opp[1], "H") !== false) { // home game $this->set_home_team($team); $this->set_away_team(Club::get_club_id_by_short($opp[0])); } else { $this->set_home_team(Club::get_club_id_by_short($opp[0])); $this->set_away_team($team); } // f*****g retarded api have to do this shit... if (sizeof($data) == 2) { // fixture played $goals = explode("-", $data[1]); if (sizeof($goals) == 1) { // cant set goals since game hasnt been played for the round $this->set_played(0); $this->set_home_goals(NULL); $this->set_away_goals(NULL); return; } else { $this->set_played(1); } if ($this->get_home_team() == $team) { // 1-0 home win $this->set_home_goals((int) $goals[0]); $this->set_away_goals((int) $goals[1]); } else { //0-1 away loss $this->set_home_goals((int) $goals[1]); $this->set_away_goals((int) $goals[0]); } } }