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?
shailesh
(Shailesh Makwana990)
January 28, 2012, 9:15am
2
Generally HTTP Are Connection less though in Web Framework used Connection less, Yii followed that one
phpnode
(Charlespick)
January 28, 2012, 12:26pm
3
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.