Sorry, but you need to login to access this location.

Duplicating a record and the associated records

Hello,

I have a database with relationships between tables.

Let's say I have a table called Movies and each Movie has many Frame.

I want users to be able to edit their Movie without affecting the Movie other users can see, which stays on-line.

So users can create a copy of the Movie in the same table and work on it. It will have the status "In progress". When the movie is ready, the old movie is deleted and the status becomes "Released". Of course, the frames have to be duplicated so that the initial movie does not change.

Do I have to write the code that creates the copy of the frames for the new movie (and all the related tables), or is there a function in Cake to perform this type of operation? This is a little bit like deleting records and the associated records, but for the addition.

Thanks!

Asked by GnarlyYoyo, on 25/4/10

2 Answers

I wrote a behavior (Copyable) that copies a record and its associated records:

http://jamienay.com/2010/03/copyable-behavior-for-cakephp-1-3-recursive-record-copying

Answered by jnayon 25/4/10

This answer works only for directly related models.

GnarlyYoyo - on 25/4/10

<< comments | comments >>
<< previous next >>

Tagged with

Rating

0

Viewed

251 times

Last Activity

on 25/4/10