Commit 8ebe9ed4 authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

Mysqli connection can set native float and int option when mysqlnd is used

parent 78ee5819
......@@ -291,21 +291,11 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract
throw new Zend_Db_Adapter_Mysqli_Exception('The Mysqli extension is required for this adapter but the extension is not loaded');
}
if (isset($this->_config['port'])) {
$port = (integer) $this->_config['port'];
} else {
$port = null;
}
// suppress connections warning, will be handled by exception thrown
@$this->_connectWithDetection((isset($this->_config['port']))
? (integer) $this->_config['port']
: null);
// Suppress connection warnings here.
// Throw an exception instead.
@$this->_connection = new mysqli(
$this->_config['host'],
$this->_config['username'],
$this->_config['password'],
$this->_config['dbname'],
$port
);
if ($this->_connection === false || mysqli_connect_errno()) {
/**
* @see Zend_Db_Adapter_Mysqli_Exception
......@@ -315,6 +305,34 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract
}
}
protected function _connectWithDetection($port) {
if (!function_exists('mysqli_get_client_stats')) {
$this->_legacyConnect($port);
return;
}
// when we use mysqlnd, we can ensure same native datatype in prepared statement and in simple queries
$this->_connection = mysqli_init();
$this->_connection->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1);
$this->_connection->real_connect($this->_config['host'],
$this->_config['username'],
$this->_config['password'],
$this->_config['dbname'],
$port);
}
protected function _legacyConnect($port) {
$this->_connection = new mysqli($this->_config['host'],
$this->_config['username'],
$this->_config['password'],
$this->_config['dbname'],
$port
);
}
/**
* Force the connection to close.
*
......
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