Duplicate a record & related records in another table

A place for users and developers of the Xataface to discuss and receive support.

Duplicate a record & related records in another table

Postby semicon_guy » Thu Mar 17, 2011 12:30 pm

I am trying to figure out a way to duplicate an existing record in Xataface, and -also- duplicate the related records that are described in relationships.ini.

For example, if I have two tables:
1) People (PersonID, Name)
2) Tasks (TaskID, PersonID, Task)
i.e. each person has multiple tasks

I would like to be able to duplicate a person and at the same time ALSO duplicate all of their associated tasks. Does Xataface include a way to do this functionality, with a trigger or something? The follow up question would be whether it supports duplicating files as well (that are on the filesystem and not a BLOB).

Thanks!
semicon_guy
 
Posts: 16
Joined: Wed Oct 13, 2010 5:05 pm

Re: Duplicate a record & related records in another table

Postby shannah » Thu Mar 17, 2011 12:40 pm

You would need a custom action to do this. The xataface copy records action doesn't deal with any relationships because it gets quite complex (some relationships need to point at the same record - some need to point at a duplicate record).

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Duplicate a record & related records in another table

Postby shannah » Thu Mar 17, 2011 1:50 pm

I suppose we could add an afterCopy() hook for the delegate class so that this method would be called after a record is copied and you can add your custom relationship copies in that method... This would be pretty easy to add.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Duplicate a record & related records in another table

Postby shannah » Thu Mar 17, 2011 2:12 pm

I have added the beforeCopy and afterCopy hooks in SVN. Here is the wiki page that describes the afterCopy hook:
http://xataface.com/wiki/afterCopy

You can add support for this by updating your copy of Dataface/CopyTool.php to the version in SVN:
http://weblite.ca/svn/dataface/core/tru ... pyTool.php

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Duplicate a record & related records in another table

Postby semicon_guy » Mon Mar 21, 2011 12:32 pm

Thanks for adding this feature. I will hopefully try it out soon and let you know!
semicon_guy
 
Posts: 16
Joined: Wed Oct 13, 2010 5:05 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 17 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved