Полный код выглядит так. А как конфигурировать через configure()? Можно пример ?
Код: Выделить всё
$config = array(
'preload'=>array('db', 'import'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),
'modules'=>array(
),
// application components
'components'=>array(
),
// uncomment the following to enable URLs in path-format
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
),
),
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=base1',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
'enableProfiling'=>true,
),
'db2'=>array(
'class'=>'system.db.CDbConnection',
'connectionString' => 'mysql:host=localhost;dbname=',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
'enableProfiling'=>true,
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
),
),
),
);
$data = BSettings::model()->find();
$config['components']['db2']['connectionString'] = 'mysql:host=localhost;dbname=blog_'.$data->db_name.'';
return $config;