Existing database. Create a Yii models using it

Hi :) I’m developing an application to work with an existing DB (not made by me, with not standard columns’ name, named in italian, in various type: int, enum, varchar and so on).

How to create a model using that existing table? How to list columns, and their data type?



Have a look at http://www.yiiframework.com/doc/blog/prototype.scaffold

Once you’ve got the yiic shell running type “model help” for options.

Hi, I’ve tried Scaffolding but it doesn’t work very well in my case. After some work I’ve overwritten table name / primary key name. My problem now is how to represent ENUM field in the form.

You can use:

CHtml::activeRadioButtonList($model, 'valuta', array('EUR'=>'Valuta EUR', 'DIN'=>'Valuta din'));

Where ‘EUR’ and ‘DIN’ are ENUM values from MySQL.