Skip to content

Commit a2d95f3

Browse files
committed
Possibility to connect to MySQL db with using unix socket connection
1 parent b6ea355 commit a2d95f3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/DB.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,13 @@ public static function initialize(
7878
if (empty($credentials)) {
7979
throw new TelegramException('MySQL credentials not provided!');
8080
}
81+
if (isset($credentials['unix_socket'])) {
82+
$dsn = 'mysql:unix_socket=' . $credentials['unix_socket'];
83+
} else {
84+
$dsn = 'mysql:host=' . $credentials['host'];
85+
}
86+
$dsn .= ';dbname=' . $credentials['database'];
8187

82-
$dsn = 'mysql:host=' . $credentials['host'] . ';dbname=' . $credentials['database'];
8388
if (!empty($credentials['port'])) {
8489
$dsn .= ';port=' . $credentials['port'];
8590
}

0 commit comments

Comments
 (0)