Add DatabaseCredentials class and implement database picker question

This commit is contained in:
Tim
2021-12-16 00:06:38 +01:00
parent d78f52b965
commit 0ff9021d6e
5 changed files with 96 additions and 3 deletions

View File

@ -8,9 +8,9 @@ class MysqliConnection
{
private mysqli $connection;
public function __construct($hostname, $user, $password)
public function __construct(DatabaseCredentials $credentials)
{
$this->connection = new mysqli($hostname, $user, $password);
$this->connection = new mysqli($credentials->getHostname(), $credentials->getUser(), $credentials->getPassword());
if ($this->connection->connect_error) {
throw new \Exception("Connection failed: " . $this->connection->connect_error);
}