Commit a6497000 authored by webchick's avatar webchick
Browse files

#561400 by drewish, Berdir: Allow specifying MySQL socket with DBTNG.

parent 70097688
......@@ -20,14 +20,17 @@ public function __construct(array $connection_options = array()) {
// 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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment