From 68d8aa8211668ee83bbefcc377615d77c9afd474 Mon Sep 17 00:00:00 2001 From: Davey Shafik Date: Tue, 11 Aug 2020 19:23:13 +0000 Subject: Allow socket connections --- lib/mysql.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/mysql.php b/lib/mysql.php index 215e045..a0ebb5a 100644 --- a/lib/mysql.php +++ b/lib/mysql.php @@ -54,6 +54,13 @@ namespace { $password = ini_get('mysqli.default_pw') ?: null; } + $socket = ''; + if (strpos($hostname, ':/') === 0) { + // it's a unix socket + $socket = $hostname; + $hostname = 'localhost'; + } + $hash = sha1($hostname . $username . $flags); /* persistent connections start with p: */ /* don't use a cached link for those */ @@ -95,7 +102,7 @@ namespace { $password, '', $port, - '', + $socket, $flags ); -- cgit v1.1