added missing named parameters, added strict_types
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
ec156db4aa
commit
30180e6d71
|
@ -1,7 +1,9 @@
|
||||||
<?php
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
error_reporting(error_level: E_ALL);
|
||||||
|
|
||||||
|
|
||||||
use PDO;
|
use PDO;
|
||||||
use PDOException;
|
use PDOException;
|
||||||
|
|
||||||
|
@ -20,7 +22,7 @@ class DatabaseConnection
|
||||||
|
|
||||||
public function __construct(private array $config)
|
public function __construct(private array $config)
|
||||||
{
|
{
|
||||||
extract($this->config);
|
extract(array: $this->config);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->dbConnection = new PDO(
|
$this->dbConnection = new PDO(
|
||||||
|
@ -29,13 +31,13 @@ class DatabaseConnection
|
||||||
password: $dbPassword
|
password: $dbPassword
|
||||||
);
|
);
|
||||||
$sql = "SHOW TABLES";
|
$sql = "SHOW TABLES";
|
||||||
$statement = $this->dbConnection->prepare($sql);
|
$statement = $this->dbConnection->prepare(query: $sql);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
$result = $statement->fetch();
|
$result = $statement->fetch();
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
// ALTER TABLE `domains` ADD `panel_id` INT NULL AFTER `id`;
|
// ALTER TABLE `domains` ADD `panel_id` INT NULL AFTER `id`;
|
||||||
echo 'Error: Cannot find tables.' . PHP_EOL;
|
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 = "
|
$sql = "
|
||||||
CREATE TABLE `apikeys` (
|
CREATE TABLE `apikeys` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
@ -44,7 +46,7 @@ class DatabaseConnection
|
||||||
`api_token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
`api_token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
|
) 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();
|
$statement->execute();
|
||||||
|
|
||||||
$sql = "
|
$sql = "
|
||||||
|
@ -56,7 +58,7 @@ class DatabaseConnection
|
||||||
`aaaa` varbinary(255) DEFAULT NULL,
|
`aaaa` varbinary(255) DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
|
) 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();
|
$statement->execute();
|
||||||
|
|
||||||
$sql = "
|
$sql = "
|
||||||
|
@ -68,7 +70,7 @@ class DatabaseConnection
|
||||||
`apikey` varbinary(255) DEFAULT NULL,
|
`apikey` varbinary(255) DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
|
) 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();
|
$statement->execute();
|
||||||
|
|
||||||
$sql = "
|
$sql = "
|
||||||
|
@ -80,7 +82,7 @@ class DatabaseConnection
|
||||||
`apikey` varbinary(255) DEFAULT NULL,
|
`apikey` varbinary(255) DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
|
) 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();
|
$statement->execute();
|
||||||
|
|
||||||
echo 'Tables have been created.' . PHP_EOL;
|
echo 'Tables have been created.' . PHP_EOL;
|
||||||
|
|
Loading…
Reference in New Issue