You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
719 B
PHP

<?php
require_once 'include/db_connect.inc.php';
function getTournaments($conn, $game = NULL){
$sql = "SELECT * FROM tournament";
if($game){
$sql = $sql." WHERE game = ?";
}
$stmt = $conn->prepare($sql);
if($game){
$stmt->bind_param('i', $game);
}
$tournaments = [];
$stmt->execute();
if ($result = $stmt->get_result()){
while ($obj = $result->fetch_assoc()){
$tournaments[$obj['id']] = [
'id' =>$obj['id'],
'name' =>$obj['name'],
'game' =>$obj['game'],
'platform' =>$obj['platform'],
'dateFrom' =>$obj['dateFrom'],
'dateTo' =>$obj['dateTo'],
'teamLimit' =>$obj['teamLimit'],
];
}
}
return $tournaments;
}
//echo (count(getTournaments($conn, 1)));
?>