l3pp4rd/DoctrineExtensions — Issue #193: Getting leaves in Nested Tree - problem
Author: IjinPL
Created: 2011-11-17 02:12:45+00:00
State: open

Hi.
To get all the leaves from the tree i implemented simple function extending NestedTreeRepository.php

```php
getEntityManager();

$leaves = $em->createQuery('SELECT p
FROM CatalogerCatalogBundle:Category p
WHERE p.id NOT IN(
SELECT DISTINCT l.parent_id
FROM CatalogerCatalogBundle:Category l
WHERE l.parent_id IS NOT NULL
)'
);

return $leaves->getResult();
}
```

To retrive parent_id I added extra field to my Category.php class, which is not accessible by default:

```php
parent_id = $parentId;
}

/**
* Get parent_id
*
* @return integer
*/
public function getParentId()
{
return $this->parent_id;
}
```

Everything works great in dev environtment, but if i'm trying to get nodes in production env. i got error 500 issue.
I'm not realy sure if it's StofDoctrineExtensionsBundle error or Doctrine error, because if I remove subquery from selset everything works fine in both environments.
Please chceck this and if u find any solution share it with me.