From 30180e6d71c9f096c0625d0e42495066d788939d Mon Sep 17 00:00:00 2001 From: tracer Date: Wed, 26 Jan 2022 19:35:57 +0100 Subject: [PATCH] added missing named parameters, added strict_types Signed-off-by: tracer --- src/Controller/DatabaseConnection.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Controller/DatabaseConnection.php b/src/Controller/DatabaseConnection.php index bb1c31e..3fc8d81 100644 --- a/src/Controller/DatabaseConnection.php +++ b/src/Controller/DatabaseConnection.php @@ -1,7 +1,9 @@ -config); + extract(array: $this->config); try { $this->dbConnection = new PDO( @@ -29,13 +31,13 @@ class DatabaseConnection password: $dbPassword ); $sql = "SHOW TABLES"; - $statement = $this->dbConnection->prepare($sql); + $statement = $this->dbConnection->prepare(query: $sql); $statement->execute(); $result = $statement->fetch(); if (empty($result)) { // ALTER TABLE `domains` ADD `panel_id` INT NULL AFTER `id`; echo 'Error: Cannot find tables.' . PHP_EOL; - if (confirm('Should I try to create them?')) { + if (confirm(message: 'Should I try to create them?')) { $sql = " CREATE TABLE `apikeys` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -44,7 +46,7 @@ class DatabaseConnection `api_token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"; - $statement = $this->dbConnection->prepare($sql); + $statement = $this->dbConnection->prepare(query: $sql); $statement->execute(); $sql = " @@ -56,7 +58,7 @@ class DatabaseConnection `aaaa` varbinary(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"; - $statement = $this->dbConnection->prepare($sql); + $statement = $this->dbConnection->prepare(query: $sql); $statement->execute(); $sql = " @@ -68,7 +70,7 @@ class DatabaseConnection `apikey` varbinary(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"; - $statement = $this->dbConnection->prepare($sql); + $statement = $this->dbConnection->prepare(query: $sql); $statement->execute(); $sql = " @@ -80,7 +82,7 @@ class DatabaseConnection `apikey` varbinary(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"; - $statement = $this->dbConnection->prepare($sql); + $statement = $this->dbConnection->prepare(query: $sql); $statement->execute(); echo 'Tables have been created.' . PHP_EOL;