Yii Framework Forum: Gii Merge not overwrite - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Gii Merge not overwrite Rate Topic: -----

#1 User is offline   iScotts 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 31-January 12

Posted 20 February 2012 - 06:17 PM

Hi all I very new to yii and I must say im loving it so far. Yet I do have one concern, I noticed that whenever I make changes to my Database and i need the changes to reflect on my Model Class, I either have to do it manually or use gii. But then gii over writes my whole file possibly deleting some custom code that i might have had.
Is there a way to make to enable gii to merge code instead of overwriting nd replacing the whole file?

If not can this be considered as a future feature, well thats if the community is also having the same problems, also if anyone has a work around can you please post it on here.

PS: Am I correct for having extra code in my Model class to begin with, or is it advisable to add all extra code in my controller?
1

#2 User is offline   tburandt 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 04-December 11

Posted 20 February 2012 - 09:05 PM

+1

This is number 1 on my list of things that need to be added/changed. Or better yet, when ever the database is changed have Gii auto update models while still keeping custom changes. This would be soooo sweet.
0

#3 User is offline   phpnode 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 18-April 11

Posted 21 February 2012 - 04:12 AM

You can achieve this by having Gii generate base classes, e.g. BaseUser that you then extend with your custom code. That way you make your changes in the User model and if you need to regenerate with Gii, you generate a new BaseUser and you don't need to touch your code.
0

#4 User is offline   iScotts 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 31-January 12

Posted 21 February 2012 - 04:59 AM

View Posttburandt, on 20 February 2012 - 09:05 PM, said:

+1

This is number 1 on my list of things that need to be added/changed. Or better yet, when ever the database is changed have Gii auto update models while still keeping custom changes. This would be soooo sweet.

Auto update is a good idea..
0

#5 User is offline   iScotts 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 31-January 12

Posted 21 February 2012 - 05:00 AM

View Postphpnode, on 21 February 2012 - 04:12 AM, said:

You can achieve this by having Gii generate base classes, e.g. BaseUser that you then extend with your custom code. That way you make your changes in the User model and if you need to regenerate with Gii, you generate a new BaseUser and you don't need to touch your code.

Ok not sure why i didnt think of this.. will have to do it this way thanks..
0

#6 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 3,317
  • Joined: 10-October 10
  • Location:Denmark

Posted 21 February 2012 - 12:52 PM

Giix does this already (Gii Extended) - personally, I like to do this by hand, but I can see your point.
"Less noise - more signal"
0

#7 User is offline   Motin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 17-May 10

Posted 27 June 2013 - 07:11 AM

Worth to mention that Giix is a fork of Gii Template Collection and that the Giix fork seems to suffer from a lack of activity currently.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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