fixed bug when no domains exist

This commit is contained in:
tracer 2024-04-17 13:14:09 +02:00
parent 8f946d9360
commit 2eb96742bb
2 changed files with 3 additions and 2 deletions

View File

@ -2,7 +2,7 @@
"name": "24unix/bindapi", "name": "24unix/bindapi",
"description": "manage Bind9 DNS server via REST API", "description": "manage Bind9 DNS server via REST API",
"version": "2023.0.1", "version": "2023.0.1",
"build_number": "334", "build_number": "335",
"authors": [ "authors": [
{ {
"name": "Micha Espey", "name": "Micha Espey",

View File

@ -245,7 +245,8 @@ readonly class DomainRepository
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql); $statement = $this->databaseConnection->getConnection()->prepare(query: $sql);
$statement->execute(); $statement->execute();
$result = $statement->fetch(); $result = $statement->fetch();
return $result['length']; // if there are not yet any domains, just return 30
return $result['length'] ?? 30;
} catch (PDOException $e) { } catch (PDOException $e) {
exit($e->getMessage()); exit($e->getMessage());
} }