*/ class TaskMapper extends QBMapper { public function __construct(IDBConnection $db) { parent::__construct($db, 'llm_tasks', Task::class); } /** * @param int $id * @return Task * @throws Exception * @throws DoesNotExistException * @throws MultipleObjectsReturnedException */ public function find(int $id): Task { $qb = $this->db->getQueryBuilder(); $qb->select(Task::$columns) ->from($this->tableName) ->where($qb->expr()->eq('id', $qb->createPositionalParameter($id))); return $this->findEntity($qb); } /** * @param int $timeout * @return int the number of deleted tasks * @throws Exception */ public function deleteOlderThan(int $timeout): int { $qb = $this->db->getQueryBuilder(); $qb->delete($this->tableName) ->where($qb->expr()->lt('last_updated', $qb->createPositionalParameter(time() - $timeout))); return $qb->executeStatement(); } public function update(Entity $entity): Entity { $entity->setLastUpdated(time()); return parent::update($entity); } }