mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
For MySQL you can now specify the socket to use using unix_socket
key in the config array. Closes #1994
This commit is contained in:
parent
9d1e3cbb05
commit
7c87e9abc1
3 changed files with 10 additions and 1 deletions
|
@ -54,6 +54,8 @@
|
|||
* For MySQL, Postgres specifies the character encoding to use when connecting to the
|
||||
* database. Uses database default not specified.
|
||||
*
|
||||
* unix_socket =>
|
||||
* For MySQL to connect via socket specify the `unix_socket` parameter instead of `host` and `port`
|
||||
*/
|
||||
class DATABASE_CONFIG {
|
||||
|
||||
|
|
|
@ -54,6 +54,8 @@
|
|||
* For MySQL, Postgres specifies the character encoding to use when connecting to the
|
||||
* database. Uses database default not specified.
|
||||
*
|
||||
* unix_socket =>
|
||||
* For MySQL to connect via socket specify the `unix_socket` parameter instead of `host` and `port`
|
||||
*/
|
||||
class DATABASE_CONFIG {
|
||||
|
||||
|
|
|
@ -147,8 +147,13 @@ class Mysql extends DboSource {
|
|||
if (!empty($config['encoding'])) {
|
||||
$flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $config['encoding'];
|
||||
}
|
||||
if (empty($config['unix_socket'])) {
|
||||
$dsn = "mysql:host={$config['host']};port={$config['port']};dbname={$config['database']}";
|
||||
} else {
|
||||
$dsn = "mysql:unix_socket={$config['unix_socket']};dbname={$config['database']}";
|
||||
}
|
||||
$this->_connection = new PDO(
|
||||
"mysql:host={$config['host']};port={$config['port']};dbname={$config['database']}",
|
||||
$dsn,
|
||||
$config['login'],
|
||||
$config['password'],
|
||||
$flags
|
||||
|
|
Loading…
Reference in a new issue