From 2e87464fc8441203f3f9d294a83c41f652e494a9 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 15 Feb 2019 22:17:41 +0000 Subject: [PATCH] initial attempt at connecting to mysql socket file through pdo --- functions.inc.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/functions.inc.php b/functions.inc.php index 387fc65f..9156cfa4 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -1503,7 +1503,14 @@ function db_connect_with_errors() { $dsn = null; if (db_mysql()) { - $dsn = "mysql:host={$CONF['database_host']};dbname={$CONF['database_name']};charset=UTF8"; + $socket = Config::read_string('database_socket'); + $database_name = Config::read_string('database_name'); + + if ($socket) { + $dsn = "mysql:unix_socket={$socket};dbname={$database_name};charset=UTF8"; + } else { + $dsn = "mysql:host={$CONF['database_host']};dbname={$database_name};charset=UTF8"; + } if (Config::bool('database_use_ssl')) { $options[PDO::MYSQL_ATTR_SSL_CA] = Config::read_string('database_ssl_ca'); $options[PDO::MYSQL_ATTR_SSL_CAPATH] = Config::read_string('database_ssl_ca_path');