From 684d6369a8997410238a188b0474443cd1719a5b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 22 Sep 2017 19:13:02 +0200 Subject: [PATCH] Better default connection return --- DataStorage/Database/DatabasePool.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/DataStorage/Database/DatabasePool.php b/DataStorage/Database/DatabasePool.php index aaec74103..5f4751454 100644 --- a/DataStorage/Database/DatabasePool.php +++ b/DataStorage/Database/DatabasePool.php @@ -77,10 +77,14 @@ class DatabasePool * * @since 1.0.0 */ - public function get(string $key = 'core') /* : ?ConnectionAbstract */ + public function get(string $key = '') /* : ?ConnectionAbstract */ { - if (!isset($this->pool[$key])) { - return null; /* todo: return nullconnection */ + if((!empty($key) && !isset($this->pool[$key])) || empty($this->pool)) { + return null; + } + + if(empty($key)) { + return reset($this->pool); } return $this->pool[$key];