我希望我的模型对多个数据库执行一些操作。假设我的模型是用户类。它扩展了 SynchroAR 类(SynchroAR 扩展了 CActiveRecord)。在用户类中:
protected function afterSave()
{
    if($this->goSynchro)
        $this->runSynchro('save');
    parent::afterSave();
}
在 SynchroAR 中:
protected function runSynchro($method)
{
    $this->goSynchro = false;
    foreach($this->entryConns as $conn)
    {
        parent::$db = $conn;
        parent::$db->setActive(true);
        call_user_func(array($this, $method));
    }
    $this->goSynchro = true;
    parent::$db = Yii::app()->usersdb;
    parent::$db->setActive(true);
}
$entryConns是一个数组,其中包含$method应该应用 的连接。目前我在$entryConns. 我打开CWebLogRoute它,它实际上执行save()了方法,但我猜它在同一个数据库上执行了两次,因为第二个数据库中的数据没有被更改。为什么?