From 1f45c2c218f4eff656c14b6d39cd9fa120d40668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 12 Aug 2021 17:29:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Pool/Connection.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/System/Pool/Connection.php b/System/Pool/Connection.php index 8f56687f..602a5e2a 100644 --- a/System/Pool/Connection.php +++ b/System/Pool/Connection.php @@ -100,17 +100,11 @@ class Connection extends Component if (($pdo = Context::getContext($coroutineName)) instanceof PDO) { return $pdo; } - - debug('mysql connect startTime ' . microtime(true)); - /** @var PDO $connections */ $connections = $this->getPool()->get($coroutineName, $this->create($coroutineName, $config)); if (Context::hasContext('begin_' . $coroutineName)) { $connections->beginTransaction(); } - - debug('mysql connect endTime ' . microtime(true)); - return Context::setContext($coroutineName, $connections); } @@ -126,6 +120,8 @@ class Connection extends Component if (Coroutine::getCid() === -1) { Runtime::enableCoroutine(false); } + debug('mysql connect startTime ' . microtime(true)); + $cds = 'mysql:dbname=' . $config['database'] . ';host=' . $config['cds']; $link = new PDO($cds, $config['username'], $config['password'], [ PDO::ATTR_EMULATE_PREPARES => false, @@ -137,6 +133,8 @@ class Connection extends Component $link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $link->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); $link->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING); + + debug('mysql connect endTime ' . microtime(true)); return $link; }; }