From 326b09893a66becec09cb5031e4aa2b4977789ae Mon Sep 17 00:00:00 2001 From: William Date: Wed, 20 Apr 2022 18:42:19 +0000 Subject: [PATCH] Delete team and related times --- app/lib/App/Timetable/TimeMapper.php | 6 ++++++ public/race/configure/teams/delete.php | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/lib/App/Timetable/TimeMapper.php b/app/lib/App/Timetable/TimeMapper.php index 1c24525..bcd9277 100644 --- a/app/lib/App/Timetable/TimeMapper.php +++ b/app/lib/App/Timetable/TimeMapper.php @@ -85,4 +85,10 @@ class TimeMapper $sth = $this->dbh->prepare('DELETE FROM tidtabell WHERE TidID = ?'); $sth->execute([$id]); } + + public function deleteByTeamId(int $team_id): void + { + $sth = $this->dbh->prepare('DELETE FROM tidtabell WHERE LagID = ?'); + $sth->execute([$team_id]); + } } \ No newline at end of file diff --git a/public/race/configure/teams/delete.php b/public/race/configure/teams/delete.php index 8a7fa1a..03c0e56 100644 --- a/public/race/configure/teams/delete.php +++ b/public/race/configure/teams/delete.php @@ -1,12 +1,17 @@ database->conn); +$time_mapper = new TimeMapper($app->database->conn); // item is NULL if not set if ($item === NULL) @@ -32,7 +37,8 @@ if (!$confirm) die(); } -// all is good, lets delete the team +// all is good, lets delete the team and related times +$time_mapper->deleteByTeamId($team->id); $team_mapper->delete($team->id); $app->session->flash("Slettet lag: {$team->name}", "success"); $app->redirect('index.php'); \ No newline at end of file