Commit
This commit is contained in:
parent
cb28dbaaba
commit
14820d90fd
@ -16,11 +16,24 @@ class TimeMapper
|
||||
|
||||
private function mapRowToTime(array $row): Time
|
||||
{
|
||||
$team = new Time();
|
||||
$team->id = $row['TidID'];
|
||||
$team->setTeamId($row['LagID']);
|
||||
$team->setDate(new DateTime($row['Tidspunkt']));
|
||||
return $team;
|
||||
$time= new Time();
|
||||
$time->id = $row['TidID'];
|
||||
$time->setTeamId($row['LagID']);
|
||||
$time->setDate(new DateTime($row['Tidspunkt']));
|
||||
return $time;
|
||||
}
|
||||
|
||||
public function getAll(): array
|
||||
{
|
||||
$sth = $this->dbh->query('SELECT * FROM tidtabell');
|
||||
$assoc_array = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$times = [];
|
||||
foreach ($assoc_array as $key => $row)
|
||||
{
|
||||
array_push($times, $this->mapRowToTime($row));
|
||||
}
|
||||
return $times;
|
||||
}
|
||||
|
||||
public function getLatestByTeamId(int $teamId): ?Time
|
||||
|
30
public/race/configure/reset.php
Normal file
30
public/race/configure/reset.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php $app = require '../../../app/inc.php';
|
||||
/**
|
||||
* Remove times from timetable and update teamtable with new times
|
||||
*/
|
||||
|
||||
use App\Teamtable\Team;
|
||||
use App\Teamtable\TeamMapper;
|
||||
use App\Timetable\Time;
|
||||
use App\Timetable\TimeMapper;
|
||||
|
||||
$teamMapper = new TeamMapper($app->database->conn);
|
||||
$timeMapper = new TimeMapper($app->database->conn);
|
||||
|
||||
// reset counters for all teams
|
||||
$teams = $teamMapper->getAll();
|
||||
|
||||
foreach ($teams as $key => $team)
|
||||
{
|
||||
$team->setRounds(0);
|
||||
$team->bestTime = NULL;
|
||||
$teamMapper->update($team);
|
||||
}
|
||||
|
||||
// delete all time records
|
||||
$times = $timeMapper->getAll();
|
||||
|
||||
foreach ($times as $key => $time)
|
||||
{
|
||||
$timeMapper->delete($time->id);
|
||||
}
|
Reference in New Issue
Block a user