Different Database For Different Countries

I wanted to buy 3 different domains in 3 different countries. I wanted to show the same website on all 3 domains but with different content and users. Is there any possibility so that I can somehow use the same yii site but just read from different database depending which domain is currently in use?

Another problem is that I will be using cronjobs to modify data in database depending on country.

You can load different config files, depending on $_SERVER[‘HTTP_HOST’] in the index.php.




switch($_SERVER['HTTP_HOST'])

{

    case 'domain1.com':

       $config = 'main_domain1.php';

       break;

    case 'domain2.com':

       $config = 'main_domain2.php'

       break;

   ....

    default:

        $config = 'main.php'

}


....

Yii::createWebApplication($config)->run();




Or merge a main.php without a db component config with different config files containing the db settings only.





switch($_SERVER['HTTP_HOST'])

{

    case 'domain1.com':

       $dbConfig = 'db1.php';

       break;

    case 'domain2.com':

       $dbConfig = 'db2.php';

       break;

   ....

    default:

        $dbConfig = 'db.php';

}




require('path/to/yii.php');


$dbCfg=require('path/to/'.$dbConfig);

$base=require('path/to/main.php');


$config=CMap::mergeArray($base, $dbCfg);


Yii::createApplication($config)->run();




See: Section Application Configurations

http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site

This wiki would help you…

http://www.yiiframework.com/wiki/78/multiple-databases-and-multiple-domains

great solutions. thanks :D