The question may make you confuse here is an explanation.
I have a module which I intend to use another database for my project.
So I set my init() like this in MyModuleModule.php
public function init()
// this method is called when the module is being created
// you may place code here to customize the module or the application
// import the module-level models and components
'db' => array(
'connectionString' => 'mysql:host=localhost;dbname=myanotherdb',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
It is what I believe it’ll alter the database connection for this module.
That means when generating a model for this module. Gii has to use this DB setting for its connection.
But it isn’t. Gii still connects to the database of the main config.
I generate model for this model using the same way as I generate for my application.
Well, I have to make a mistake somewhere. More over I’ve used yii-environment extension you can see here. Don’t know if this has to do something with my problem.
So do you guys have any idea what is wrong? Thanks a lot.