1
0

PropertyMapper.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\Db;
  8. use OCP\AppFramework\Db\QBMapper;
  9. use OCP\IDBConnection;
  10. /**
  11. * @template-extends QBMapper<Property>
  12. */
  13. class PropertyMapper extends QBMapper {
  14. private const TABLE_NAME = 'properties';
  15. public function __construct(IDBConnection $db) {
  16. parent::__construct($db, self::TABLE_NAME, Property::class);
  17. }
  18. /**
  19. * @return Property[]
  20. */
  21. public function findPropertyByPathAndName(string $userId, string $path, string $name): array {
  22. $selectQb = $this->db->getQueryBuilder();
  23. $selectQb->select('*')
  24. ->from(self::TABLE_NAME)
  25. ->where(
  26. $selectQb->expr()->eq('userid', $selectQb->createNamedParameter($userId)),
  27. $selectQb->expr()->eq('propertypath', $selectQb->createNamedParameter($path)),
  28. $selectQb->expr()->eq('propertyname', $selectQb->createNamedParameter($name)),
  29. );
  30. return $this->findEntities($selectQb);
  31. }
  32. }