show statistics of the stations is now possible

This commit is contained in:
2022-06-08 15:59:53 +02:00
parent 0962a70cd7
commit 13025edc3e
4 changed files with 129 additions and 26 deletions

View File

@@ -5,18 +5,6 @@ function handle_pdo_exception($e) {
die();
}
function get_Station() {
try {
$dbh = new PDO('mysql:host=mysql;dbname=ksp', 'grisu', 'secret');
foreach($dbh->query('SELECT * from Station') as $row) {
print_r($row);
}
$dbh = null;
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
function check_user_id($con, $user_id) {
try {
$stmt = $con->prepare('SELECT user_id FROM users WHERE user_id = :user_id limit 1');
@@ -75,6 +63,17 @@ function get_stations($con) {
}
}
function get_stations_all($con) {
try {
$stmt = $con->prepare("SELECT * FROM Station");
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt;
} catch(PDOException $e) {
handle_pdo_exceptio($e);
}
}
function get_teams($con) {
try {
$stmt = $con->prepare("SELECT name, feuerwehr FROM Mannschaft");
@@ -95,4 +94,26 @@ function get_total_score($con) {
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
function get_station_name($con, $s_id) {
try {
$stmt = $con->prepare("SELECT name FROM Station WHERE s_id= :s_id");
$stmt->execute(['s_id' => $s_id]);
$stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt->fetch();
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
function get_station($con, $s_id) {
try {
$stmt = $con->prepare("SELECT M.name as Name, M.feuerwehr as Feuerwehr, P.punkte as Punkte, P.zeit as Zeit FROM Punkte as P, Station as S, Mannschaft as M WHERE P.s_id = S.s_id AND S.s_id = :s_id AND M.m_id = P.m_id ORDER BY Punkte DESC");
$stmt->execute(['s_id' => $s_id]);
$stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt;
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}