This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Nico Kaiser

By: a guest on Apr 20th, 2010  |  syntax: PHP  |  size: 0.55 KB  |  views: 117  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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) { }
clone this paste RAW Paste Data