I have already generated the model and controllers files for a table in my database using the model and crud commands. Now that I need to add a column in the table, I am not able to figure out whether there is any inbuilt feature in Yii for that as in ROR or I need to manually code for it.
Considering the generality of this question, I think it would have been asked before. But I could not find any similar topic. Please mention the reference if there is any.
I understand the general of the question will try to think something on that.
On the other way what i do is keep the files that will be changed like old_files.php and then diff the new from the old, even though there not big changes when you add something ( model will only be the main affected php file indeed as i think )
if you add columns to a table that already has its own model class, you should maybe think in updating :
[list=1]
[*]validation rules
[*]label attributes (if the new column is to be modified by user inputs)
[*]relations (if this new column is a foreign key)
[*] the search method (generated by yiic…if you use it of course)
[/list]
Most of the time, for a ‘simple’ column added to the table, 1. and 2. are enough. Let Yii discover what columns you’ve added ! … and simply use it like $myModel->my_new_column.
hi kumar,
if you add columns to a table that already has its own model class, you should maybe think in updating :
validation rules
label attributes (if the new column is to be modified by user inputs)
relations (if this new column is a foreign key)
the search method (generated by yiic..if you use it of course)
Most of the time, for a 'simple' column added to the table, 1. and 2. are enough. Let Yii discover what columns you've added ! <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' /> ... and simply use it like $myModel->my_new_column.
hope that helps
ciao
<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='B)' />
i have applied all the above but still it gives me error…