For MySQL you can now specify the socket to use using unix_socket key in the config array. Closes #1994

This commit is contained in:
ADmad 2011-09-16 13:37:22 +05:30
parent 9d1e3cbb05
commit 7c87e9abc1
3 changed files with 10 additions and 1 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -147,8 +147,13 @@ class Mysql extends DboSource {
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