Fix MySQL UNIX socket support (#5166)

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 <kgraefe@paktolos.net>
This commit is contained in:
Konrad Gräfe
2023-03-05 18:00:04 +01:00
committed by GitHub
parent 068d18b69b
commit 16472fd427

View File

@@ -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'];
}