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 {