From e69d12dbf69b5883eedd9d93a0cf6eaf1b5fd683 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 14 Feb 2017 23:27:31 +0100 Subject: [PATCH] Throw on connection data error --- .../Database/Connection/MysqlConnection.php | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/DataStorage/Database/Connection/MysqlConnection.php b/DataStorage/Database/Connection/MysqlConnection.php index 8cdb173c1..f91021701 100644 --- a/DataStorage/Database/Connection/MysqlConnection.php +++ b/DataStorage/Database/Connection/MysqlConnection.php @@ -62,9 +62,34 @@ class MysqlConnection extends ConnectionAbstract */ public function connect(array $dbdata = null) /* : void */ { - $this->close(); - $this->dbdata = isset($dbdata) ? $dbdata : $this->dbdata; + + if(!isset($this->dbdata['db'])) { + throw new \Exception('db'); + } + + if(!isset($this->dbdata['host'])) { + throw new \Exception('host'); + } + + if(!isset($this->dbdata['port'])) { + throw new \Exception('port'); + } + + if(!isset($this->dbdata['database'])) { + throw new \Exception('database'); + } + + if(!isset($this->dbdata['login'])) { + throw new \Exception('login'); + } + + if(!isset($this->dbdata['password'])) { + throw new \Exception('password'); + } + + $this->close(); + $this->prefix = $dbdata['prefix'] ?? ''; try {