From ba681024057838c96cbd7c84b4f35477079fbd16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 1 Sep 2023 10:54:55 +0800 Subject: [PATCH] eee --- Connection.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Connection.php b/Connection.php index 4529d70..184f3e6 100644 --- a/Connection.php +++ b/Connection.php @@ -380,8 +380,8 @@ class Connection extends Component */ public function newConnect(): PDO { - return new PDO('mysql:dbname=' . $this->database . ';host=' . $this->cds, - $this->username, $this->password, array_merge($this->attributes, [ + $pdo = new PDO('mysql:dbname=' . $this->database . ';host=' . $this->cds, + $this->username, $this->password, [ PDO::ATTR_CASE => PDO::CASE_NATURAL, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, @@ -389,7 +389,11 @@ class Connection extends Component PDO::ATTR_EMULATE_PREPARES => true, PDO::ATTR_TIMEOUT => $this->timeout, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . $this->charset - ])); + ]); + array_walk($this->attributes, function ($value, $key) use ($pdo) { + $pdo->setAttribute($key, $value); + }); + return $pdo; }