[Solved] Using Multiple Database Connection Not Working For Extension

I am doing multiple database connection using the tutorial at http://www.yiiframework.com/wiki/544/multiple-database-connection-select-database-based-on-login-user-id-dynamic/ . The code is working fine in the model. But the problem is I am using an extension where I am using db connection using Yii::app()->db; Here I am getting exception Property "CWebApplication.dbadvert" is not defined. The controller of the extension is extended from CExtController. Please help.

Which Extension?

I myself developed the extension. How can I access a model from CExtController?

I have searched for using multiple db’s in an app, and I remember seeing how to switch db’s in the models _init() function. What I’m getting at is that I remember seeing code to getModule(), getDb(), and other ways getting information about the app. If you don’t specifically set the db connection in the Ext, you may have to using the get/setDb() stuff.

One other thought may be that you have to load the models in your Ext. I am not sure how isolated an extesnion is from the app.

I wrote the query for the extension in a model as functions. and in the CExtController created an instance of the model. Then I called those functions and everything is working fine.