From 0a67c168628698c4121fcec11872c3ec8534ecf6 Mon Sep 17 00:00:00 2001 From: tracer Date: Wed, 6 Apr 2022 16:29:14 +0200 Subject: [PATCH] added findFirst() Signed-off-by: tracer --- src/Repository/NameserverRepository.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Repository/NameserverRepository.php b/src/Repository/NameserverRepository.php index 4f33721..8e8a32a 100644 --- a/src/Repository/NameserverRepository.php +++ b/src/Repository/NameserverRepository.php @@ -42,6 +42,28 @@ class NameserverRepository } + /** + * @return \App\Entity\Nameserver + */ + public function findFirst(): Nameserver + { + $nameservers = []; + $sql = " + SELECT id, name, a, aaaa, apikey + FROM " . DatabaseConnection::TABLE_NAMESERVERS . " + ORDER BY name"; + + try { + $statement = $this->databaseConnection->getConnection()->prepare(query: $sql); + $statement->execute(); + $result = $statement->fetch(mode: PDO::FETCH_ASSOC); + return new Nameserver(name: $result['name'], id: $result['id'], a: $result['a'], aaaa: $result['aaaa'], apikey: $result['apikey']); + } catch (PDOException $e) { + exit($e->getMessage()); + } + } + + /** * @param int $id *