Revision #2 was created by Steve Friedl on Dec 21, 2010, 12:58:20 AM.
Fixed broken link to other wiki article
Content
[...]
--------------------------
Every model defined in `protected/models/*.php` includes `GetDbConnection()` in the base class, and it returns a handle to the DB connection object for the primary database. We need to override this method in the models representing the advertising database to return the second DB connection.
Though it's possible to do this in the model definition file itself, this doesn't scale well as it would duplicate a lot of code if more than one model lives in the Advertising database. Better is to use a custom wrapper class to `CActiveRecord` where this can be centralized.
The notion of custom wrapper classes is described in <a href=[this wiki article](http://www.yiiframework.com/wiki/121/extending-common-classes-to-allow-better-customization/">this wiki article</a>), and we'll assume that you've created a `protected/components/MyActiveRecord.php` file, and teachaught all of your model files to extend `MyActiveRecord` rather than `CActiveRecord`.