Jump to content

multiple db calls in update callback

  • Please log in to reply
2 replies to this topic

#1 ssfthurber



  • Members
  • PipPip
  • 27 posts

Posted 04 June 2013 - 03:33 PM

instead of update in place my application requires versioning. so in the event of an update i need to end up with the old version of the record marked as expired and a new version inserted.  my thought was to use update callback to both insert the new record and update the old version marking it as expired.

all the callback examples show return with a single db call. is this a limitation or is there a way to code two db calls, as required by my use case?

#2 davidoster


    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 04 June 2013 - 10:33 PM

I would use http://www.grocerycr...k_before_update

and within this function I would do two things,

1. change the versioning field to mark this record as an older one and

2. with the same(previous) data insert a new record


The return is used when some (or all of the data) need to be altered before they are sent to the db, as it is in your case.

But at the same time you can do as many db calls within this callback. There is no limitation what you can do.



rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---



David Oster aka George Pasparakis,

#3 ssfthurber



  • Members
  • PipPip
  • 27 posts

Posted 04 June 2013 - 11:06 PM

yes, this is the way to go. thanks.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users