Gii Module Generators

I’m back on Yii after a long break, and I see that there is a new code generator Gii. I’ve generated a module - but there doesn’t seem to be an option to generate models etc within that module. Do I have to generate a model using Gii, then copy it to the appropriate place in the module previously created?

:P running into the same issue

Did you try clicking on the "Model Path" field? That will allow you to specify where to generate the models.

I tried the “Model Path” field and it works as long as the database is set up in the site’s config/main.php file as ‘db’.

The problem I have is that most of my Modules have their own database and it’s set up in the CWebModule’s init method with something like the following:


	'db_module' => array(

		'class' => 'CDbConnection',

		'connectionString' => $connectionString,

		'emulatePrepare' => true,

		'username' => $username,

		'password' => $password,

		'charset' => 'utf8',





There is no way to tell gii which database component to use. The only way I know to get around it for now is to copy the db_module array into config/main.php and rename it to ‘db’

It would be nice to be able to direct gii to a different database component.

I don’t post here often (I even forgot my last username… ha…) so I just want to take this time to say “Thanks!” for all your hard work on this incredible framework. I’ve been using it for quite a while now and written several sites with it. It’s the best!

Another nice addition would be automatically adding the following to the Model:

public static $db;

public function getDbConnection()



        return self::$db;




        if(self::$db instanceof CDbConnection)



            return self::$db;



            throw new CDbException(Yii::t('yii','Active Record requires a "db" CDbConnection application component.'));



Replace the "Yii::app()->db_module" with database component name.

I know you can create templates, but I don’t know how to change the module name in it.