How do I keep a database connected

I know that we can use


Yii::app()->db

to get Yii’s db connection easily, but what if I have a second database, how can I globalize a database connection?

I now use Mongodb(a nosql database) with mysql, but I have to connect to it every time I use it with


$m=new Mongo();

Is it possible to connect to it once and always use this connection?

Generally HTTP Are Connection less though in Web Framework used Connection less, Yii followed that one

Use an application component if you need "global" access to it and configure it in your main config. Then you can access it via Yii::app()->mongo or whatever.