Yii Framework Forum: How to save only modified fields - Yii Framework Forum

Jump to content

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

How to save only modified fields Rate Topic: ***** 1 Votes

#1 User is offline   _bogus_ 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 14-January 10

Posted 16 January 2010 - 10:01 AM

Hey there!

How do I save only modified fields ? I mean, i have a form (the same for inserting, im using the default generated CRUD), so if the users leave a field blank, it should not update that field. In my case I also have two comboboxes that has a value=0 option, and it should not save those too. If there's no modified field, so it leaves the record without any changes. How do I do that?

Thanks in advance
1

#2 User is offline   kenci 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 08-October 08

Posted 17 January 2010 - 06:04 AM

No one?
0

#3 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 17 January 2010 - 06:28 AM

http://www.yiiframew...ord#save-detail

Look at the second parameter. But you have to generate it manually.
1

#4 User is offline   kenci 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 08-October 08

Posted 17 January 2010 - 07:43 AM

Is this the only possibility, to set the 'attributes' property manually? In Propel you haven't to do this.
0

#5 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:47 AM

Try to search the forums, there has been a similar discussion some months ago. And not sure, there might even be an extension doing that. The main principle is: After loading a record (afterFind()) you have to copy the attributes (e.g. to private array in the record) in order to find out, which of them have changed when you want to save the record again.
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