Skip to content

Commit

Permalink
added support of driver_options to Mysqli Driver
Browse files Browse the repository at this point in the history
  • Loading branch information
alex347 committed Dec 1, 2012
1 parent 2cdd471 commit 75728de
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion library/Zend/Db/Adapter/Driver/Mysqli/Connection.php
Expand Up @@ -166,7 +166,23 @@ public function connect()
$port = (isset($p['port'])) ? (int) $p['port'] : null;
$socket = (isset($p['socket'])) ? $p['socket'] : null;

$this->resource = new \mysqli($hostname, $username, $password, $database, $port, $socket);
$this->resource = new \mysqli();
$this->resource->init();

if (!empty($p['driver_options'])) {
foreach ($p['driver_options'] as $option => $value) {
if (is_string($option)) {
// Suppress warnings here
// Ignore it if it's not a valid constant
$option = @constant(strtoupper($option));
if ($option === null)
continue;
}
$this->resource->options($option, $value);
}
}

$this->resource->real_connect($hostname, $username, $password, $database, $port, $socket);

if ($this->resource->connect_error) {
throw new Exception\RuntimeException(
Expand Down

0 comments on commit 75728de

Please sign in to comment.