Change db conection for inserts and updates

Hello!

Im using multiple databases, a master one (this is the default one, stored in Yii::app()->db ) for INSERT and UPDATE, and a backup server (stored in Yii::app()->db_slave) for just SELECT, how can I make a YII extension that automatically will change the setActive database to the master or slave depending of the type of query just before the query is executed?

Thank you in advance

hello emily! for know im doing the setActive manually in each method of the model :(