Difference between #3 and #4 of
Multiple-database support in Yii

Revision #4 has been created by phazei on Aug 2, 2012, 8:18:18 PM with the memo:

Added note for 1.1.11 and multiple database support in Gii.
« previous (#3)


Title unchanged

Multiple-database support in Yii

Category unchanged


Yii version unchanged

Tags unchanged


Content changed

Once this is defined, the second database is referred to as `Yii::app()->dbadvert` rather than `Yii::app()->db` (of course, the first is still available).

But we can do much better integration than this, starting with Gii and ending with AR support.
Using Gii
Gii can use multiple database connections in Yii > 1.1.11.
If you are using a previous version, 
Gii only knows how to use the primary database connection, so for a brief time while creating models/controllers/crud, you'll have to edit your `protected/config/main.php` file to temporarily make the advertising database the primary `db` connection:

// protected/config/main.php
'components' => array(
# 'db' => array(
20 0
Viewed: 113 721 times
Version: 1.1
Category: How-tos
Tags: database
Written by: Steve Friedl
Last updated by: phazei
Created on: Dec 21, 2010
Last updated: 5 years ago
Update Article


View all history