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.
150 lines
2.6 KiB
PHP
150 lines
2.6 KiB
PHP
<?php
|
|
require_once 'include/db_connect.inc.php';
|
|
|
|
function getUser($conn, $id){
|
|
|
|
// With prepared statements (security reasons)
|
|
$sql = "SELECT * FROM user WHERE id = ?";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bind_param('i', $id);
|
|
|
|
$line = [];
|
|
|
|
$stmt->execute();
|
|
if ($result = $stmt->get_result()){
|
|
//$user = $result->fetch_assoc();
|
|
while ($obj = $result->fetch_assoc()){
|
|
$line[$obj['id']] = [
|
|
'id' =>$obj['id'],
|
|
'username' =>$obj['username'],
|
|
'password' =>$obj['password']
|
|
];
|
|
}
|
|
|
|
}
|
|
|
|
return $line;
|
|
|
|
//$result->close();
|
|
|
|
//var_dump($line);
|
|
|
|
}
|
|
|
|
|
|
function getMatchTeams($conn, $id){
|
|
|
|
// With prepared statements (security reasons)
|
|
$sql = "
|
|
SELECT t.id, t.name
|
|
FROM team t
|
|
INNER JOIN match__team mt ON mt.team = t.id
|
|
INNER JOIN `match` m ON m.id = mt.`match`
|
|
WHERE m.id = ?
|
|
";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bind_param('i', $id);
|
|
|
|
$line = [];
|
|
|
|
$stmt->execute();
|
|
if ($result = $stmt->get_result()){
|
|
//$user = $result->fetch_assoc();
|
|
while ($obj = $result->fetch_assoc()){
|
|
$line[$obj['id']] = [
|
|
'id' =>$obj['id'],
|
|
'name' =>$obj['name'],
|
|
];
|
|
}
|
|
|
|
}
|
|
|
|
return $line;
|
|
|
|
//$result->close();
|
|
|
|
//var_dump($line);
|
|
|
|
}
|
|
|
|
function getTeamPlayers($conn, $id){
|
|
|
|
// With prepared statements (security reasons)
|
|
$sql = "
|
|
SELECT ga.id, ga.ign, ga.rating, t.id AS team_id
|
|
FROM game_account ga
|
|
INNER JOIN team__player tp ON tp.game_account = ga.id
|
|
INNER JOIN team t ON tp.team = t.id
|
|
WHERE t.id = ?
|
|
";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bind_param('i', $id);
|
|
|
|
$line = [];
|
|
|
|
$stmt->execute();
|
|
if ($result = $stmt->get_result()){
|
|
//$user = $result->fetch_assoc();
|
|
while ($obj = $result->fetch_assoc()){
|
|
$line[$obj['id']] = [
|
|
'id' =>$obj['id'],
|
|
'ign' =>$obj['ign'],
|
|
'rating' =>$obj['rating'],
|
|
'team_id' =>$obj['team_id'],
|
|
];
|
|
}
|
|
|
|
}
|
|
|
|
return $line;
|
|
|
|
//$result->close();
|
|
|
|
//var_dump($line);
|
|
}
|
|
|
|
function getTournaments($conn){
|
|
|
|
// With prepared statements (security reasons)
|
|
$sql = "
|
|
SELECT *
|
|
FROM tournament t
|
|
WHERE dateTo >= curdate()
|
|
";
|
|
$stmt = $conn->prepare($sql);
|
|
|
|
$line = [];
|
|
|
|
$stmt->execute();
|
|
if ($result = $stmt->get_result()){
|
|
while ($obj = $result->fetch_assoc()){
|
|
$line[$obj['id']] = [
|
|
'id' =>$obj['id'],
|
|
'name' =>$obj['name'],
|
|
'game' =>$obj['game'],
|
|
'playform' =>$obj['platform'],
|
|
'dateFrom' =>$obj['dateFrom'],
|
|
'dateTo' =>$obj['dateTo'],
|
|
];
|
|
}
|
|
|
|
}
|
|
|
|
return $line;
|
|
|
|
//$result->close();
|
|
|
|
var_dump($line);
|
|
|
|
}
|
|
|
|
//getMatchTeams($conn, 1);
|
|
//getTeamPlayers($conn, 1);
|
|
getTournaments($conn);
|
|
|
|
//$result = $conn->query("SELECT * FROM user LIMIT 10");
|
|
|
|
//$conn->close();
|
|
|
|
?>
|