modified version update

This commit is contained in:
tracer 2024-04-30 13:35:21 +02:00
parent c6ece08a0b
commit 06df37ed3c
2 changed files with 13 additions and 7 deletions

View File

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

View File

@ -40,13 +40,19 @@ readonly class SettingsRepository
public function set(string $name, string $value): int
{
$sql = "
INSERT INTO " . DatabaseConnection::TABLE_SETTINGS . " (name, value)
VALUES (:name, :value)
ON DUPLICATE KEY UPDATE
value = :value
$currentSetting = $this->findByName($name);
if ($currentSetting !== false) {
$sql = "
UPDATE " . DatabaseConnection::TABLE_SETTINGS . "
SET value = :value
WHERE name = :name
";
} else {
$sql = "
INSERT INTO " . DatabaseConnection::TABLE_SETTINGS . " (name, value)
VALUES (:name, :value)
";
}
try {
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql);