Copy a Doctrine object with all relations

Posted by elManolo on Stack Overflow See other posts from Stack Overflow or by elManolo
Published on 2010-03-01T16:59:19Z Indexed on 2010/04/14 20:33 UTC
Read the original article Hit count: 152

Filed under:
|
|

I want to copy a record with all his relations.

I'm trying with:

$o = Doctrine::getTable('Table')->Find(x); 
$copy = $object->copy();
$relations = $o->getRelations();

foreach ($relations as $name => $relation) {
  $copy->$relation = $object->$relation->copy();
} 

$copy->save();

This code doesn't works, but I think it's on the way.

© Stack Overflow or respective owner

Related posts about doctrine

Related posts about php