From af0ece9daee4725d94ada16cef026903e3aa85b3 Mon Sep 17 00:00:00 2001 From: Pierre Baret Date: Wed, 27 Jan 2016 16:56:10 +0100 Subject: [PATCH] Keep master connection --- src/Driver/Connection/MasterSlavesConnection.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Driver/Connection/MasterSlavesConnection.php b/src/Driver/Connection/MasterSlavesConnection.php index a4047dd..38afd54 100644 --- a/src/Driver/Connection/MasterSlavesConnection.php +++ b/src/Driver/Connection/MasterSlavesConnection.php @@ -33,6 +33,9 @@ private function checkSlaves(array $slaves) public function connectToMaster() { + if ($this->currentConnectionParams === $this->master) { + return; + } $this->currentConnectionParams = $this->master; $this->currentSlave = null; $this->wrappedConnection = null; @@ -60,6 +63,9 @@ public function getCurrentConnection() protected function wrap() { + if ($this->wrappedConnection !== null) { + return $this->wrappedConnection; + } if ($this->currentConnectionParams === null) { $this->currentSlave = $this->chooseASlave(); $this->currentConnectionParams = $this->currentSlave ? $this->slaves[$this->currentSlave] : $this->master;