summaryrefslogtreecommitdiffstats
path: root/lib/mysql.php
diff options
context:
space:
mode:
authorDavey Shafik <me@daveyshafik.com>2020-08-11 19:23:13 +0000
committerDavey Shafik <me@daveyshafik.com>2020-08-11 19:23:13 +0000
commit68d8aa8211668ee83bbefcc377615d77c9afd474 (patch)
tree01c8bf157cb512739d8e4deefe50ad81ce64a021 /lib/mysql.php
parent81720edfa0a801efdcb6a8b19c014b9a7bb437f9 (diff)
downloadphp7-mysql-shim-68d8aa8211668ee83bbefcc377615d77c9afd474.zip
php7-mysql-shim-68d8aa8211668ee83bbefcc377615d77c9afd474.tar.gz
php7-mysql-shim-68d8aa8211668ee83bbefcc377615d77c9afd474.tar.bz2
Allow socket connections
Diffstat (limited to 'lib/mysql.php')
-rw-r--r--lib/mysql.php9
1 files changed, 8 insertions, 1 deletions
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
);