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