Commit 387eb545 authored by mikeSimonson's avatar mikeSimonson

Allow to connect without a dbname param

The PDO connection allow the instantiation of the connection even if the dbname
parameter isn't present. This change is there to make sure both behave the same way.
parent 5eb36c7a
...@@ -51,6 +51,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar ...@@ -51,6 +51,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
{ {
$port = isset($params['port']) ? $params['port'] : ini_get('mysqli.default_port'); $port = isset($params['port']) ? $params['port'] : ini_get('mysqli.default_port');
$socket = isset($params['unix_socket']) ? $params['unix_socket'] : ini_get('mysqli.default_socket'); $socket = isset($params['unix_socket']) ? $params['unix_socket'] : ini_get('mysqli.default_socket');
$dbname = isset($params['dbname']) ? $params['dbname'] : null;
$flags = isset($driverOptions[static::OPTION_FLAGS]) ? $driverOptions[static::OPTION_FLAGS] : null; $flags = isset($driverOptions[static::OPTION_FLAGS]) ? $driverOptions[static::OPTION_FLAGS] : null;
...@@ -61,7 +62,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar ...@@ -61,7 +62,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
$previousHandler = set_error_handler(function () { $previousHandler = set_error_handler(function () {
}); });
if ( ! $this->_conn->real_connect($params['host'], $username, $password, $params['dbname'], $port, $socket, $flags)) { if ( ! $this->_conn->real_connect($params['host'], $username, $password, $dbname, $port, $socket, $flags)) {
set_error_handler($previousHandler); set_error_handler($previousHandler);
$sqlState = 'HY000'; $sqlState = 'HY000';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment