Task is to run UPDATE/INSERT queries on main connection (db) and distribute SELECT queries between multiple (db, db2, db3). I have two application components: db and db2. Code in my base model:
protected function beforeFind()
{
parent::$db = $this->getConnectionForSelect();
parent::beforeFind();
}
protected function afterFind()
{
parent::$db = null;
parent::afterFind();
}
Somehow it sometimes writes to db2. What am I doing wrong?