From 16472fd427a4058811784d49228e074ddbb7bead Mon Sep 17 00:00:00 2001 From: Konrad Gräfe Date: Sun, 5 Mar 2023 18:00:04 +0100 Subject: Fix MySQL UNIX socket support (#5166) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MySQL uses different parameters for passing UNIX socket pathts (unix_socket) and TCP sockets (host) in contrast to PosgreSQL which uses one for both (host). Signed-off-by: Konrad Gräfe --- lib/Minz/ModelPdo.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index 85796b53a..3bcf87247 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -51,7 +51,13 @@ class Minz_ModelPdo { switch ($db['type']) { case 'mysql': - $dsn = 'mysql:host=' . (empty($dbServer['host']) ? $db['host'] : $dbServer['host']) . ';charset=utf8mb4'; + $dsn = 'mysql:'; + if (empty($dbServer['host'])) { + $dsn .= 'unix_socket=' . $db['host']; + } else { + $dsn .= 'host=' . $dbServer['host']; + } + $dsn .= ';charset=utf8mb4'; if (!empty($db['base'])) { $dsn .= ';dbname=' . $db['base']; } -- cgit v1.2.3