Nextcloud-App/lib/Db/UserMapper.php

32 lines
880 B
PHP
Raw Permalink Normal View History

<?php
namespace OCA\UPschooling\Db;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\Entity;
use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
class UserMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'upschooling_users', MatrixUser::class);
}
/**
* @param string $userId
* @return Entity|MatrixUser
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws DoesNotExistException
* @throws \OCP\DB\Exception
*/
public function find(string $userId): MatrixUser {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('upschooling_users')
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
return $this->findEntity($qb);
}
}