Select Queries Distribution Between Multiple Connections

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();



    protected function afterFind()


        parent::$db = null;



Somehow it sometimes writes to db2. What am I doing wrong?


Could you give as more details ?

Is getConnectionForSelect your method ?