Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MySQL: Allow session variables to be set via config. Fixes #3329

  • Loading branch information...
commit 052ba522b0998009e083b1eb9776831bf61ee0a3 1 parent 396e9bc
@cbandy cbandy authored
Showing with 13 additions and 0 deletions.
  1. +12 −0 classes/kohana/database/mysql.php
  2. +1 −0  config/database.php
View
12 classes/kohana/database/mysql.php
@@ -79,6 +79,18 @@ public function connect()
// Set the character set
$this->set_charset($this->_config['charset']);
}
+
+ if ( ! empty($this->_config['connection']['variables']))
+ {
+ // Set session variables
+ foreach ($this->_config['connection']['variables'] as $variable => $value)
+ {
+ mysql_query(
+ 'SET SESSION '.$variable.' = '.$this->quote($value),
+ $this->_connection
+ );
+ }
+ }
}
/**
View
1  config/database.php
@@ -14,6 +14,7 @@
* string username database username
* string password database password
* boolean persistent use persistent connections?
+ * array variables system variables as "key => value" pairs
*
* Ports and sockets may be appended to the hostname.
*/
Please sign in to comment.
Something went wrong with that request. Please try again.