1
0
Fork 0

Merge pull request #11265 from k-alin/6606-k-alin-mysql-unix-socket

Enable MySQL unix socket connection
This commit is contained in:
Hypolite Petovan 2022-02-25 10:36:43 -05:00 committed by GitHub
commit 419fe67c6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 0 deletions

View file

@ -114,6 +114,7 @@ class Database
$pass = trim($this->configCache->get('database', 'password'));
$db = trim($this->configCache->get('database', 'database'));
$charset = trim($this->configCache->get('database', 'charset'));
$socket = trim($this->configCache->get('database', 'socket'));
if (!(strlen($server) && strlen($user))) {
return false;
@ -135,6 +136,10 @@ class Database
$connect .= ";charset=" . $charset;
}
if ($socket) {
$connect .= ";$unix_socket=" . $socket;
}
try {
$this->connection = @new PDO($connect, $user, $pass, [PDO::ATTR_PERSISTENT => $persistent]);
$this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, $this->pdo_emulate_prepares);
@ -160,6 +165,11 @@ class Database
if ($charset) {
$this->connection->set_charset($charset);
}
if ($socket) {
$this->connection->set_socket($socket);
}
}
}