Skip to content
Permalink
Browse files

For MySQL you can now specify the socket to use using `unix_socket` k…

…ey in the config array. Closes #1994
  • Loading branch information...
ADmad committed Sep 16, 2011
1 parent 9d1e3cb commit 7c87e9abc1205aa1a54d27e64ffecfabf3302b89
@@ -54,6 +54,8 @@
* For MySQL, Postgres specifies the character encoding to use when connecting to the
* database. Uses database default not specified.
*
* unix_socket =>
* For MySQL to connect via socket specify the `unix_socket` parameter instead of `host` and `port`
*/
class DATABASE_CONFIG {

@@ -54,6 +54,8 @@
* For MySQL, Postgres specifies the character encoding to use when connecting to the
* database. Uses database default not specified.
*
* unix_socket =>
* For MySQL to connect via socket specify the `unix_socket` parameter instead of `host` and `port`
*/
class DATABASE_CONFIG {

@@ -147,8 +147,13 @@ public function connect() {
if (!empty($config['encoding'])) {
$flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $config['encoding'];
}
if (empty($config['unix_socket'])) {
$dsn = "mysql:host={$config['host']};port={$config['port']};dbname={$config['database']}";
} else {
$dsn = "mysql:unix_socket={$config['unix_socket']};dbname={$config['database']}";
}
$this->_connection = new PDO(
"mysql:host={$config['host']};port={$config['port']};dbname={$config['database']}",
$dsn,
$config['login'],
$config['password'],
$flags

0 comments on commit 7c87e9a

Please sign in to comment.
You can’t perform that action at this time.