Yii Framework Forum: Updating Active Records? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Updating Active Records? Rate Topic: -----

#1 User is offline   Ryan Zec 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 15-January 10

Posted 16 January 2010 - 09:11 PM

Let say I have a table that is mapped to an active record model. I add in a bunch of custom logic to the model and now I have added 15 new fields to the table. Is there a way for me to regenerate the model to proper configure those 15 new fields without erasing my custom logic I have built?

In the framework I was building, when I did model code generation I generated 2 files, a base file and then a model file for each model. After that when I regenerated the models, I would only update the base one which stored all the field configuration stuff. That way the user could add all the custom logic in the model file that extends the base one and not worry about regenerating the model code when the table changes. Does something like this exist with Yii?
0

#2 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,013
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 17 January 2010 - 11:17 AM

Usually you don't have to adjust your models when you add new db fields - except rules() maybe. The rules that get autogenerated from the yiic "model" command are only for quickstart anyway. In most cases they'll need some manual tuning. So: No command to update the models but it shouldn't be a big deal to do so manually.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users