you can now edit, add and delete results

This commit is contained in:
Grisu
2022-09-22 14:17:29 +02:00
parent c3873744be
commit e62be84d35
5 changed files with 174 additions and 40 deletions

View File

@@ -469,4 +469,64 @@ function update_team_fire_department($con, $m_id, $dep) {
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
function get_direct_points($con, $s_id) {
try {
$stmt = $con->prepare("SELECT direkte_punkte FROM Station WHERE s_id = :s_id");
$stmt->execute(['s_id' => $s_id]);
$stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt;
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
function write_result_db($con, $s_id, $m_id, $result) {
try {
$stmt = $con->prepare("INSERT INTO Ergebnisse (s_id, m_id, erg) VALUES (?, ?, ?)");
$stmt->bindParam(1, $s_id, PDO::PARAM_INT);
$stmt->bindParam(2, $m_id, PDO::PARAM_INT);
$stmt->bindParam(3, $result, PDO::PARAM_INT);
$stmt->execute();
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
function get_results($con, $s_id) {
try {
$stmt = $con->prepare("SELECT * FROM Ergebnisse WHERE s_id = :s_id ORDER BY erg DESC");
$stmt->execute(['s_id' => $s_id]);
$stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt;
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
function update_result_db($con, $s_id, $m_id, $result) {
try {
$stmt = $con->prepare("UPDATE Ergebnisse SET erg = ? WHERE s_id = ? AND m_id = ?");
$stmt->bindParam(1, $result, PDO::PARAM_INT);
$stmt->bindParam(2, $s_id, PDO::PARAM_INT);
$stmt->bindParam(3, $m_id, PDO::PARAM_INT);
$stmt->execute();
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
function get_result_team_station($con, $s_id, $m_id) {
try {
$stmt = $con->prepare("SELECT * FROM Ergebnisse WHERE s_id = ? AND m_id = ?");
$stmt->bindParam(1, $s_id, PDO::PARAM_INT);
$stmt->bindParam(2, $m_id, PDO::PARAM_INT);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$result = $stmt->fetch()['erg'];
return $result;
} catch( PDOException $e) {
handle_pdo_exception($e);
}
}