Skip to content

Commit

Permalink
MySQL: Allow session variables to be set via config. Fixes #3329
Browse files Browse the repository at this point in the history
  • Loading branch information
cbandy committed Jul 2, 2011
1 parent 396e9bc commit 052ba52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions classes/kohana/database/mysql.php
Expand Up @@ -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
);
}
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions config/database.php
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 052ba52

Please sign in to comment.