I'd like to set up once, anywhere to be able to access this object from the controllers, views, models, widgets, …
Quote
Because CDbConnection extends from CApplicationComponent, we can also use it as an application component. To do so, configure in a db (or other name) application component in the application configuration as follows,
I can't set up in the config file, because my credentials for the (second) database access can change.
I extended CActiveRecord, as said here http://www.yiiframew…ic,2347.0.html, and also extend CController overwriting init(), where I define the db connection if not already defined.
As drawn here http://www.yiiframew…ide/basics.mvc, I think that CController is one of the first element loaded (and widget is the last before the layout ).