mirror of
https://github.com/nextcloud/app_api.git
synced 2026-01-13 20:19:21 +00:00
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\AppAPI\Db\TextProcessing;
|
|
|
|
use OCP\AppFramework\Db\DoesNotExistException;
|
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
|
use OCP\AppFramework\Db\QBMapper;
|
|
use OCP\DB\Exception;
|
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
|
use OCP\IDBConnection;
|
|
|
|
/**
|
|
* @template-extends QBMapper<TextProcessingProviderQueue>
|
|
*/
|
|
class TextProcessingProviderQueueMapper extends QBMapper {
|
|
public function __construct(IDBConnection $db) {
|
|
parent::__construct($db, 'ex_text_processing_q');
|
|
}
|
|
|
|
/**
|
|
* @param int $id
|
|
*
|
|
* @throws DoesNotExistException if not found
|
|
* @throws MultipleObjectsReturnedException if more than one result
|
|
* @throws Exception
|
|
*
|
|
* @return TextProcessingProviderQueue
|
|
*/
|
|
public function getById(int $id): TextProcessingProviderQueue {
|
|
$qb = $this->db->getQueryBuilder();
|
|
$qb->select('*')
|
|
->from($this->tableName)
|
|
->where(
|
|
$qb->expr()->eq('id', $qb->createNamedParameter($id))
|
|
);
|
|
return $this->findEntity($qb);
|
|
}
|
|
|
|
/**
|
|
* @throws Exception
|
|
*/
|
|
public function removeAllOlderThenThat(int $overdueTime): int {
|
|
$qb = $this->db->getQueryBuilder();
|
|
$qb->delete($this->tableName)
|
|
->where(
|
|
$qb->expr()->gte($qb->createNamedParameter(time() - $overdueTime, IQueryBuilder::PARAM_INT), 'created_time')
|
|
);
|
|
return $qb->executeStatement();
|
|
}
|
|
}
|