SHARE
TWEET

Nico Kaiser

a guest Apr 20th, 2010 121 Never
  1. <?php
  2.  
  3. use Doctrine\Common\Util\Debug;
  4.  
  5. require 'init.php';
  6.  
  7. // Create a parent group (id 1) and a child group (id 2)
  8. $group1 = new \Entities\Group;
  9. $group2 = new \Entities\Group;
  10. $group2->parent = $group1;
  11. $group1->children->add($group2);
  12. $em->persist($group1);
  13. $em->flush();
  14.  
  15. $em->clear();
  16.  
  17. $group3 = $em->find('Entities\Group', $group2->id); // Load child group first (id 2)
  18. $group4 = $em->find('Entities\Group', $group1->id); // Load parent group (id 1)
  19. // $group3 (id 2) should be a child of (id 1)
  20. foreach ($group4->children as $child) { }
RAW Paste Data
Top