Mysql And Mssql Database

Is it possible in Yii to have 2 database connection?

One for MySQL and another to MSSQL, MySQL will be used for username and password authentication of yii application and other for database query used for reports?

Yes, you can

Just read this wiki:

Be careful when using multiple databases.

It works fine with AR because each model can be linked to its own DB.

But DAO sql statements use a single connection to a single DB. So you have to use separate sql requests to the separate DBs and then join them later if needed.

Maybe wait for Yii2?


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

			'emulatePrepare' => true,

			'username' => 'XXX',

			'password' => 'XXX',

			'charset' => 'utf8',

            'class' => 'CDbConnection',




                'connectionString' => 'sqlsrv:server=XXX\SQLEXPRESS;Database=XXX_XXX;',

                'username' => 'sa',

                'password' => 'XXX',

                'charset' => 'GB2312',             


I already tried, the connection works for mssql but in gii the tables wont’ appear only mssql database tables.