Browse Source

do not switch connection when in a transaction.

tags/2.0.0-rc
Qiang Xue 10 years ago
parent
commit
c16e5e4240
  1. 4
      framework/db/Command.php

4
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 {

Loading…
Cancel
Save