Commit d83ec137 authored by marcini's avatar marcini

Added flags support for mysqli::real_connect in Mysqli driver. This is...

Added flags support for mysqli::real_connect in Mysqli driver. This is necessary if you want to set connection options like compression or SSL encryption.
parent 3faa3a65
......@@ -33,6 +33,11 @@ class MysqliConnection implements Connection, PingableConnection
*/
private $_conn;
/**
* @var string
*/
private $flagsOptionName = 'flags';
/**
* @param array $params
* @param string $username
......@@ -46,6 +51,8 @@ class MysqliConnection implements Connection, PingableConnection
$port = isset($params['port']) ? $params['port'] : ini_get('mysqli.default_port');
$socket = isset($params['unix_socket']) ? $params['unix_socket'] : ini_get('mysqli.default_socket');
$flags = isset($driverOptions[$this->flagsOptionName]) ? $driverOptions[$this->flagsOptionName] : null;
$this->_conn = mysqli_init();
$this->setDriverOptions($driverOptions);
......@@ -53,7 +60,7 @@ class MysqliConnection implements Connection, PingableConnection
$previousHandler = set_error_handler(function () {
});
if ( ! $this->_conn->real_connect($params['host'], $username, $password, $params['dbname'], $port, $socket)) {
if ( ! $this->_conn->real_connect($params['host'], $username, $password, $params['dbname'], $port, $socket, $flags)) {
set_error_handler($previousHandler);
throw new MysqliException($this->_conn->connect_error, $this->_conn->sqlstate, $this->_conn->connect_errno);
......@@ -190,6 +197,10 @@ class MysqliConnection implements Connection, PingableConnection
foreach ($driverOptions as $option => $value) {
if ($option === $this->flagsOptionName) {
continue;
}
if (!in_array($option, $supportedDriverOptions, true)) {
throw new MysqliException(
sprintf($exceptionMsg, 'Unsupported', $option, $value)
......
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