mail_calendar_sync/lib/Db/ConfigMapper.php
2026-02-09 23:02:34 -05:00

45 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\MailCalendarSync\Db;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
/**
* @extends QBMapper<Config>
*/
class ConfigMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'mcs_config', Config::class);
}
/**
* @throws DoesNotExistException
*/
public function findByUserId(string $userId): Config {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
return $this->findEntity($qb);
}
/**
* @return Config[]
*/
public function findAllEnabled(): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('enabled', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT)));
return $this->findEntities($qb);
}
}