diff --git a/lib/Db/DiffTask.php b/lib/Db/DiffTask.php new file mode 100644 index 0000000..628b3c3 --- /dev/null +++ b/lib/Db/DiffTask.php @@ -0,0 +1,28 @@ +addType('id','integer'); + $this->addType('groupfolderId','integer'); + } + + public function jsonSerialize() { + return [ + 'id' => $this->id, + 'groupfolderId' => $this->groupfolderId, + 'snapshotId' => $this->snapshotId, + 'timestamp' => $this->timestamp, + ]; + } +} \ No newline at end of file diff --git a/lib/Db/DiffTaskMapper.php b/lib/Db/DiffTaskMapper.php new file mode 100644 index 0000000..b1811c6 --- /dev/null +++ b/lib/Db/DiffTaskMapper.php @@ -0,0 +1,37 @@ + + */ +class DiffTaskMapper extends QBMapper { + + public function __construct(IDBConnection $db) { + parent::__construct($db, 'groupfolder_snapshots_tasks', DiffTask::class); + } + + public function find(int $id, string $userId) { + $qb = $this->db->getQueryBuilder(); + + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) + ->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); + + return $this->findEntity($qb); + } + + public function findAll(string $userId) { + $qb = $this->db->getQueryBuilder(); + + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); + + return $this->findEntities($qb); + } + +} \ No newline at end of file