Dynamically Change The Cdbauthmanager Connectionid

Hi.

I’m opening this topic to ask if someone can help me in a problem that i have.

I have the following on my "config/main.php" file:




(...)

'authManager'=>array(

'class'=>'CDbAuthManager',

        'connectionID'=>'db',

                    

),


          

'db'=>array(

	'connectionString' => 'mysql:host=localhost;dbname=general',

	'emulatePrepare' => true,

	'username' => 'root',

	'password' => '',

	'charset' => 'utf8',

),

(...)



My question is, how can i change dynamically the connectionID from ‘authManager’ component?

Any help is much appreciated.

Thank You.

Hi,

You can have two database like below main.php

	'db'=>array(


		'connectionString' => 'mysql:host=localhost;dbname=e-learning',


		'emulatePrepare' => true,

[size=2] [/size][size=2]‘username’ => ‘root’,[/size]

		'password' => '',


		'charset' => 'utf8',


	),


	'addressdb'=>array(


		'connectionString' => 'mysql:host=127.0.0.1;dbname=address',


		'emulatePrepare' => true,


		'username' => 'root',


		'password' => '',


		'charset' => 'utf8',


		'class'   => 'CDbConnection'


	),

In model

access like this…u have to overide this method…if you dont override . u can access db directly

/**

 * @return CDbConnection


 */


public function getDbConnection(){


	return Yii::app()->addressdb;


}

In this way u can dynamically access db or addressdb…

I hope it will help to solve your problem…