Merge pull request #11265 from k-alin/6606-k-alin-mysql-unix-socket
Enable MySQL unix socket connection
This commit is contained in:
commit
419fe67c6c
4 changed files with 19 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue