diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-05-05 06:28:39 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-05-05 06:28:39 +0000 |
commit | a649700010bee6c5ffd48cdcfe792658715d534d (patch) | |
tree | 6b184111448db343fd6141cc5b149de41f0e0589 /includes/database/mysql/database.inc | |
parent | 70097688f47fe4ae0d9151f4cc71248dc43b5633 (diff) | |
download | brdo-a649700010bee6c5ffd48cdcfe792658715d534d.tar.gz brdo-a649700010bee6c5ffd48cdcfe792658715d534d.tar.bz2 |
#561400 by drewish, Berdir: Allow specifying MySQL socket with DBTNG.
Diffstat (limited to 'includes/database/mysql/database.inc')
-rw-r--r-- | includes/database/mysql/database.inc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/includes/database/mysql/database.inc b/includes/database/mysql/database.inc index 249db5234..d46708f3f 100644 --- a/includes/database/mysql/database.inc +++ b/includes/database/mysql/database.inc @@ -20,14 +20,17 @@ class DatabaseConnection_mysql extends DatabaseConnection { // MySQL never supports transactional DDL. $this->transactionalDDLSupport = FALSE; - // Default to TCP connection on port 3306. - if (empty($connection_options['port'])) { - $connection_options['port'] = 3306; - } - $this->connectionOptions = $connection_options; - $dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . $connection_options['port'] . ';dbname=' . $connection_options['database']; + // The DSN should use either a socket or a host/port. + if (isset($connection_options['unix_socket'])) { + $dsn = 'mysql:unix_socket=' . $connection_options['unix_socket']; + } + else { + // Default to TCP connection on port 3306. + $dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . (empty($connection_options['port']) ? 3306 : $connection_options['port']); + } + $dsn .= ';dbname=' . $connection_options['database']; parent::__construct($dsn, $connection_options['username'], $connection_options['password'], array( // So we don't have to mess around with cursors and unbuffered queries by default. PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE, |