one question on overriding getDbConnection when using multiple databases

Currently, if we want to use multiple databases, the solution seems to be set multiple db components in config/main.php such as db, db2,db3, etc.

And then override getDbConnection in CActiveRecord class like

Replace "self::$db=Yii::app()->getDb();" with "self::$db=Yii::app()->db2;"

(see http://www.yiiframew…ic,2102.0.html)

However, this means for every Yii new release, we have to change the CActiveRecord.php file.

I understand it is a good practice to NOT touch the Yii base and put everything in our apps.  So should we create a ticket for Yii to support multiple databases natively without touching the CActiveRecord class?

You should create a base AR class by extending CActiveRecord and overriding its getDbConnection method. Then all your other AR classes should extend from this base AR class.

Great idea. I am implementing this into my hitcounter module.