*/ class TaskMapper extends QBMapper { /** * @param IDBConnection $db */ public function __construct(IDBConnection $db) { parent::__construct($db, 'mail_cc_tasks'); } /** * @return Task * @throws DoesNotExistException * @throws Exception * @throws MultipleObjectsReturnedException */ public function findNext(): Task { $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from($this->getTableName()) ->orderBy('id', 'ASC') ->setMaxResults(1); return $this->findEntity($qb); } /** * @param int $id * @return Task * @throws DoesNotExistException * @throws Exception * @throws MultipleObjectsReturnedException */ public function findById(int $id): Task { $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from($this->getTableName()) ->where( $qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)) ); return $this->findEntity($qb); } /** * @param int $mailboxId * @return Task * @throws DoesNotExistException * @throws Exception * @throws MultipleObjectsReturnedException */ public function findByMailbox(int $mailboxId): Task { $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from($this->getTableName()) ->where( $qb->expr()->eq('mailbox_id', $qb->createNamedParameter($mailboxId, IQueryBuilder::PARAM_INT)) ); return $this->findEntity($qb); } }