mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-09 16:12:49 +08:00
改进mysql驱动对socket支持
This commit is contained in:
@@ -31,12 +31,15 @@ class Mysql extends Connection
|
|||||||
*/
|
*/
|
||||||
protected function parseDsn($config)
|
protected function parseDsn($config)
|
||||||
{
|
{
|
||||||
$dsn = 'mysql:dbname=' . $config['database'] . ';host=' . $config['hostname'];
|
if (!empty($config['socket'])) {
|
||||||
if (!empty($config['hostport'])) {
|
$dsn = 'mysql:unix_socket=' . $config['socket'];
|
||||||
$dsn .= ';port=' . $config['hostport'];
|
} elseif (!empty($config['hostport'])) {
|
||||||
} elseif (!empty($config['socket'])) {
|
$dsn = 'mysql:host=' . $config['hostname'] . ';port=' . $config['hostport'];
|
||||||
$dsn .= ';unix_socket=' . $config['socket'];
|
} else {
|
||||||
|
$dsn = 'mysql:host=' . $config['hostname'];
|
||||||
}
|
}
|
||||||
|
$dsn .= ';dbname=' . $config['database'];
|
||||||
|
|
||||||
if (!empty($config['charset'])) {
|
if (!empty($config['charset'])) {
|
||||||
$dsn .= ';charset=' . $config['charset'];
|
$dsn .= ';charset=' . $config['charset'];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user