Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 052ba522b0998009e083b1eb9776831bf61ee0a3 1 parent 396e9bc
Chris Bandy cbandy authored

Showing 2 changed files with 13 additions and 0 deletions. Show diff stats Hide diff stats

  1. +12 0 classes/kohana/database/mysql.php
  2. +1 0  config/database.php
12 classes/kohana/database/mysql.php
@@ -79,6 +79,18 @@ public function connect()
79 79 // Set the character set
80 80 $this->set_charset($this->_config['charset']);
81 81 }
  82 +
  83 + if ( ! empty($this->_config['connection']['variables']))
  84 + {
  85 + // Set session variables
  86 + foreach ($this->_config['connection']['variables'] as $variable => $value)
  87 + {
  88 + mysql_query(
  89 + 'SET SESSION '.$variable.' = '.$this->quote($value),
  90 + $this->_connection
  91 + );
  92 + }
  93 + }
82 94 }
83 95
84 96 /**
1  config/database.php
@@ -14,6 +14,7 @@
14 14 * string username database username
15 15 * string password database password
16 16 * boolean persistent use persistent connections?
  17 + * array variables system variables as "key => value" pairs
17 18 *
18 19 * Ports and sockets may be appended to the hostname.
19 20 */

0 comments on commit 052ba52

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