This commit is contained in:
William 2022-03-21 11:39:50 +01:00
parent 739f583a33
commit 87c1a0c1c5

View File

@ -36,9 +36,21 @@ class TimeMapper
return $times; return $times;
} }
public function getLatest(): ?Time
{
$sth = $this->dbh->prepare('SELECT * FROM tidtabell ORDER BY Tidspunkt DESC LIMIT 1');
$sth->execute();
$row = $sth->fetch(PDO::FETCH_ASSOC);
if ($row)
{
return $this->mapRowToTime($row);
}
return NULL;
}
public function getLatestByTeamId(int $teamId): ?Time public function getLatestByTeamId(int $teamId): ?Time
{ {
$sth = $this->dbh->prepare('SELECT * FROM tidtabell WHERE LagID = ? ORDER BY Tidspunkt DESC'); $sth = $this->dbh->prepare('SELECT * FROM tidtabell WHERE LagID = ? ORDER BY Tidspunkt DESC LIMIT 1');
$sth->execute([$teamId]); $sth->execute([$teamId]);
$row = $sth->fetch(PDO::FETCH_ASSOC); $row = $sth->fetch(PDO::FETCH_ASSOC);
if ($row) if ($row)
@ -50,7 +62,7 @@ class TimeMapper
public function get(int $id): ?Time public function get(int $id): ?Time
{ {
$sth = $this->dbh->prepare('SELECT * FROM tidtabell WHERE TidID = ?'); $sth = $this->dbh->prepare('SELECT * FROM tidtabell WHERE TidID = ? LIMIT 1');
$sth->execute([$id]); $sth->execute([$id]);
$row = $sth->fetch(PDO::FETCH_ASSOC); $row = $sth->fetch(PDO::FETCH_ASSOC);
if ($row) if ($row)