This repository has been archived on 2025-02-01. You can view files and clone it, but cannot push or open issues or pull requests.
accm-website/includes/tournaments/TournamentLister.inc.php
2010-11-13 20:51:50 +01:00

46 lines
1.4 KiB
PHP

<?php
include_once './includes/database/MySQLDatabase.inc.php';
include_once './includes/tournaments/Tournament.inc.php';
include_once './includes/utils/MapperUtils.inc.php';
/**
* This class allows for easy listings of tournaments.
*
* @author Thomas Schwery <thomas.schwery@epfl.ch>
*/
class TournamentLister {
public static function getAllTournaments() {
return TournamentLister::getTournaments("");
}
public static function getTournamentsByDate($from, $to) {
$from = DateFormatter::formatSQL($from);
$to = DateFormatter::formatSQL($to);
return TournamentLister::getTournaments("WHERE date BETWEEN '$from' AND '$to'");
}
public static function getTournament($name, $location, $date, $type, $comments) {
$restriction = "WHERE date = '" . DateFormatter::formatSQL($date) . "'";
$restriction .=" AND location = '" . $location . "' AND type = '" . $type . "'";
return TournamentLister::getTournaments($restriction);
}
private static function getTournaments($restriction) {
$sql = "SELECT * FROM tournaments $restriction ORDER BY date DESC;";
$result = MySQLDatabase::getInstance()->runRequest($sql);
if ($result) {
$result1 = array_map("mapIdentifierToTournament", $result);
return $result1;
} else {
return array();
}
}
}
?>