From b841dbd6227c28947e005f24522961a31863cc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sat, 5 Sep 2020 01:35:52 +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, 5 insertions(+), 5 deletions(-) diff --git a/System/Pool/Connection.php b/System/Pool/Connection.php index 225a0cff..1db0b4aa 100644 --- a/System/Pool/Connection.php +++ b/System/Pool/Connection.php @@ -177,7 +177,6 @@ class Connection extends Pool } for ($i = 0; $i < 10 - $this->size($name); $i++) { $this->push($name, $this->createConnect($config['cds'], $config['username'], $config['password'])); - $this->incr($name); } return $this; } @@ -218,12 +217,11 @@ class Connection extends Pool private function nowClient($coroutineName, $config) { $this->success('create db client -> ' . $config['cds'] . ':' . $this->hasCreate[$coroutineName] . ':' . $this->size($coroutineName)); - $client = $this->createConnect($config['cds'], $config['username'], $config['password']); + $client = $this->createConnect($coroutineName, $config['cds'], $config['username'], $config['password']); if (isset(Context::getContext('begin_' . $coroutineName)[Coroutine::getCid()])) { $number = Context::getContext('begin_' . $coroutineName)[Coroutine::getCid()]; $number > 0 && $client->beginTransaction(); } - $this->incr($coroutineName); return $client; } @@ -319,13 +317,14 @@ class Connection extends Pool /** + * @param $coroutineName * @param $cds * @param $username * @param $password * @return PDO * @throws Exception */ - public function createConnect($cds, $username, $password) + public function createConnect($coroutineName, $cds, $username, $password) { try { $link = new PDO($cds, $username, $password, [ @@ -337,6 +336,7 @@ class Connection extends Pool $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); + $this->incr($coroutineName); return $link; } catch (\Throwable $exception) { if ($exception->getCode() !== 2006) { @@ -344,7 +344,7 @@ class Connection extends Pool throw new Exception($exception->getMessage()); } $this->addError($cds . ' -> ' . $exception->getMessage()); - return $this->createConnect($cds, $username, $password); + return $this->createConnect($coroutineName, $cds, $username, $password); } }