31 lines
918 B
PHP
31 lines
918 B
PHP
<?php namespace MapGuesser\Repository;
|
|
|
|
use DateTime;
|
|
use Generator;
|
|
use SokoWeb\Database\Query\Select;
|
|
use MapGuesser\PersistentData\Model\MultiRoom;
|
|
|
|
class MultiRoomRepository
|
|
{
|
|
public function getById(int $id): ?MultiRoom
|
|
{
|
|
return \Container::$persistentDataManager->selectFromDbById($id, MultiRoom::class);
|
|
}
|
|
|
|
public function getByRoomId(string $roomId): ?MultiRoom
|
|
{
|
|
$select = new Select(\Container::$dbConnection);
|
|
$select->where('room_id', '=', $roomId);
|
|
|
|
return \Container::$persistentDataManager->selectFromDb($select, MultiRoom::class);
|
|
}
|
|
|
|
public function getAllExpired(): Generator
|
|
{
|
|
$select = new Select(\Container::$dbConnection);
|
|
$select->where('updated', '<', (new DateTime('-7 day'))->format('Y-m-d H:i:s'));
|
|
|
|
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, MultiRoom::class);
|
|
}
|
|
}
|