From c16e5e4240369bf611b5fea82aa6f69809504d4f Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 11 Jul 2014 22:39:07 -0400 Subject: [PATCH] do not switch connection when in a transaction. --- framework/db/Command.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framework/db/Command.php b/framework/db/Command.php index ccd44a7..79d3c54 100644 --- a/framework/db/Command.php +++ b/framework/db/Command.php @@ -160,6 +160,10 @@ class Command extends \yii\base\Component $sql = $this->getSql(); + if ($this->db->getTransaction()) { + // master is in a transaction. use the same connection. + $forRead = false; + } if ($forRead || $forRead === null && $this->db->getSchema()->isReadQuery($sql)) { $pdo = $this->db->getSlavePdo(); } else {