Skip to content
Browse files

added support of driver_options to Mysqli Driver

  • Loading branch information...
1 parent 2cdd471 commit 75728de8a06564d3ff28b5d699884838d05c549c @alex347 committed Dec 1, 2012
Showing with 17 additions and 1 deletion.
  1. +17 −1 library/Zend/Db/Adapter/Driver/Mysqli/Connection.php
View
18 library/Zend/Db/Adapter/Driver/Mysqli/Connection.php
@@ -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(

0 comments on commit 75728de

Please sign in to comment.
Something went wrong with that request. Please try again.