Issues arrises are Parked domains technology.
I parked 3 domains and pointing to same web folder (Where is Yii).
In the Index file. made changes to conditional config file.
$hostname = $_SERVER['SERVER_NAME'];
switch (strtolower($hostname)) {
case 'abc.com';
case 'www.abc.com';
$config = dirname(__FILE__) . '/protected/config/abc.php';
// database 1
break;
case 'master.com';
case 'www.master.com';
$config = dirname(__FILE__) . '/protected/config/master.php';
// database 2
break;
case 'xyz.com';
case 'www.xyz.com';
$config = dirname(__FILE__) . '/protected/config/xyz.php';
// database 3
break;
default:
$config = dirname(__FILE__) . '/protected/config/master.php';
}
made 3 more config file.
In the master config i used 3 db connections:
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=db',
'emulatePrepare' => true,
'username' => 'xxx',
'password' => 'xxx',
'charset' => 'utf8',
),
'db2'=>array(
'connectionString' => 'mysql:host=localhost;dbname=db2',
'class'=>'CDbConnection',
'emulatePrepare' => true,
'username' => 'xxx',
'password' => 'xxx',
'charset' => 'utf8',
),
'db3'=>array(
'connectionString' => 'mysql:host=localhost;dbname=db3',
'class'=>'CDbConnection',
'emulatePrepare' => true,
'username' => 'xxx',
'password' => 'xxx',
'charset' => 'utf8',
),
And for data models i used Gustavo’s Extension Multiactive Record
Now the final part is how can i make a model which is point to a table(table exist in all 3 db’s) dynamically.
For example: i have a controller in master site to controll other site users data i call siteEdit action which list all the 3 other sites in a grid.
i call the sites user edit button then it call the relevant site’s user grid view,How can i achieve this,Currently its only calling that table which is mentioned in connectionId db but not dynamically changed.