Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My Answer involves not using DQL and instead creating a NestedSetManager which has access to your DBAL connection so you can use SQL. I never felt like the ORM's did a good job with NestedSets query logic. </p> <p>With a <code>NestedSetManager</code>, you can then write a bunch of clean methods and it's really simple because all these queries are well documented. See <a href="http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/" rel="nofollow">this link</a>. Some of the method in my NestedSetManager are:</p> <pre><code>setNode(); setRoot(); loadNestedSet(); moveNodeUp(); modeNodeDown(); getRootNode(); addNodeSibling(); getNodesByDepth(); getParents(); getNodePath(); childExists(); addChildToNode(); renameNode(); deleteNode(); // And many more </code></pre> <p>You can have a ball and create a lot of create NestedSet functionality if you're not tied down by an ORM's somewhat complex functionality. </p> <p>Also -- Symfony2 makes all this really really easy. You create your NestedSetManager class file and reference it in your Services.yml and pass in your Dbal connection. Mine looks like this:</p> <pre><code>services: manager.nestedset: class: Acme\CoreBundle\Manager\NestedSetManager arguments: [ @database_connection ] </code></pre> <p>you can then access your nestedsets with:</p> <pre><code>$path = $this-&gt;get('manager.nestedset')-&gt;setNode(4)-&gt;getNodePath(); // in your controller </code></pre> <p>Moral of the story, ORM/NestedSets drove me bonkers and this solution work really well. If you're being forced to use DQL and have no other options, this answer probably wont be acceptable.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload