From d520b5fbc46c412ad7a8b8b24eec99f148ea14c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Tue, 20 Sep 2022 18:23:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiri-engine/Pool/Connection.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kiri-engine/Pool/Connection.php b/kiri-engine/Pool/Connection.php index 5063aed5..53b7c98a 100644 --- a/kiri-engine/Pool/Connection.php +++ b/kiri-engine/Pool/Connection.php @@ -91,14 +91,15 @@ class Connection extends Component /** * @param mixed $config + * @param bool $isMaster * @return PDO|null - * @throws Exception + * @throws Kiri\Exception\ConfigException */ - public function get(mixed $config): ?PDO + public function get(mixed $config, bool $isMaster = false): ?PDO { $minx = Config::get('databases.pool.min', 1); - return $this->pool->get($config['cds'], $this->generate($config), $minx); + return $this->pool->get($config['cds'] . ($isMaster ? 'master' : 'slave'), $this->generate($config), $minx); } @@ -189,7 +190,8 @@ class Connection extends Component /** * @throws Exception */ - public function flush($coroutineName, $minNumber = 1) { + public function flush($coroutineName, $minNumber = 1) + { $this->pool->flush($coroutineName, $minNumber); }