added findFirst()

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-04-06 16:29:14 +02:00
parent b90d91fda2
commit 0a67c16862
1 changed files with 22 additions and 0 deletions

View File

@ -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
*