Accounts: Add account detail page

This commit is contained in:
Lexi / Zoe 2021-07-30 22:30:30 +02:00
parent 985f46c652
commit 4e8d879008
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
8 changed files with 182 additions and 5 deletions

View file

@ -3,6 +3,7 @@ declare(strict_types=1);
namespace MailAccountAdmin\Repositories;
use MailAccountAdmin\Exceptions\AccountNotFoundException;
use PDO;
class AccountRepository extends BaseRepository
@ -32,4 +33,16 @@ class AccountRepository extends BaseRepository
$statement->execute($queryParams);
return $statement->fetchAll(PDO::FETCH_ASSOC);
}
public function fetchAccountById(int $accountId): array
{
$statement = $this->pdo->prepare('SELECT * FROM mail_users WHERE user_id = :user_id LIMIT 1');
$statement->execute(['user_id' => $accountId]);
if ($statement->rowCount() < 1) {
throw new AccountNotFoundException("Account with user ID '$accountId' was not found.");
}
return $statement->fetch(PDO::FETCH_ASSOC);
}
}