public function selectMatches($con) { base::checkcon($con, __FUNCTION__); $sql = "select matches.*, alliances.* from alliances\n INNER JOIN matches\n ON (matches.CompetitionID = " . $this->ID . " and \n alliances.MatchID = matches.ID)\n order by matches.Number, alliances.Color"; // print $sql; $result = mysqli_query($con, $sql); if (!$result) { die('Error: ' . mysqli_error($con)); } $matches = array(); while ($row = mysqli_fetch_array($result)) { $match = new match(); $match->Competition = this; $match->Time = $row['Time']; $match->Number = $row['Number']; $match->Round = $row['Round']; $match->ID = $row['MatchID']; $a1 = new alliance($row->Color == 'red'); $a1->set($row); $row = mysqli_fetch_array($result); $a2 = new alliance($row->Color == 'red'); $a2->set($row); if ($a1->Color == 'red') { $match->RedAlliance = $a1; $match->BlueAlliance = $a2; } else { $match->RedAlliance = $a2; $match->BlueAlliance = $a1; } array_push($matches, $match); } mysqli_free_result($result); return $matches; }
public static function select($con, $number) { base::checkcon($con, __FUNCTION__); if (!$con) { die('selectTeam error: no connection.'); } $query = "SELECT * FROM robots where TeamNumber = " . $number; // print "$query\n"; $result = mysqli_query($con, $query); $row = mysqli_fetch_assoc($result); if (!$row) { return null; } else { return new robot($row); } }
public function selectGames($con) { base::checkcon($con, __FUNCTION__); $sql = "select * from games where MatchID = " . $this->ID; $result = mysqli_query($con, $sql); if (!$result) { die('Error: ' . mysqli_error($con)); } $games = array(); while ($row = mysqli_fetch_assoc($result)) { $game = new game($row); array_push($games, $game); } mysqli_free_result($result); return $games; }
public function select($con, $matchid, $teamnumber) { base::checkcon($con, __FUNCTION__); $sql = sprintf("select * from games where MatchID = %s and TeamNumber = %s", $matchid, $teamnumber); $result = mysqli_query($con, $sql); if (!$result) { die('Error: ' . mysqli_error($con)); } $row = mysqli_fetch_assoc($result); mysqli_free_result($result); if (!$row) { return null; } else { $game = new game($row); return $game; } }