Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Doctrine\Common\Util\Debug;
- require 'init.php';
- // Create a parent group (id 1) and a child group (id 2)
- $group1 = new \Entities\Group;
- $group2 = new \Entities\Group;
- $group2->parent = $group1;
- $group1->children->add($group2);
- $em->persist($group1);
- $em->flush();
- $em->clear();
- $group3 = $em->find('Entities\Group', $group2->id); // Load child group first (id 2)
- $group4 = $em->find('Entities\Group', $group1->id); // Load parent group (id 1)
- // $group3 (id 2) should be a child of (id 1)
- foreach ($group4->children as $child) { }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement