Sfoglia il codice sorgente

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>
Konrad Gräfe 3 anni fa
parent
commit
16472fd427
1 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 7 1
      lib/Minz/ModelPdo.php

+ 7 - 1
lib/Minz/ModelPdo.php

@@ -51,7 +51,13 @@ class Minz_ModelPdo {
 
 
 		switch ($db['type']) {
 		switch ($db['type']) {
 			case 'mysql':
 			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'])) {
 				if (!empty($db['base'])) {
 					$dsn .= ';dbname=' . $db['base'];
 					$dsn .= ';dbname=' . $db['base'];
 				}
 				}