title: Doctrine DQL returning flat array from join
body: <p>I am selecting 3 entities via regular LEFT JOIN in DQL. They are related via join tables which also have entities defined for them as well as annotated relationships.
  The query executes without issue but my results are returned as a flat array. I would expect an array with the three entities as array elements for each index:</p>
  
  <pre><code>SELECT e1, e2, e3 FROM AppBundle:EntityOne
  JOIN AppBundle:JoinEntityOneWithTwo e1_2 WITH e1_2.entity1 = e1.id
  JOIN AppBundle:EntityTwo e2 WITH e1_2.entity2 = e2.id
  JOIN AppBundle:JoinEntityOneWithThree e1_3 WITH e1_3.entity1 = e1.id
  JOIN AppBundle:EntityThree e3 WITH e3.id = e1_3.entity3
  WHERE e1.some_field IN ('some','values','in','e1');
  </code></pre>
  
  <p>When I call <code>getResult()</code> on the query, either hydrating as an object or an array, I get a flat results set:</p>
  
  <pre><code>array(
   /AppBundle/Entity/EntityOne ( ... ),
   /AppBundle/Entity/EntityTwo ( ... ),
   /AppBundle/Entity/EntityThree  ( ... ),
   /AppBundle/Entity/EntityOne ( ... ),
   /AppBundle/Entity/EntityTwo ( ... ),
   /AppBundle/Entity/EntityThree  ( ... ),
   /AppBundle/Entity/EntityTwo ( ... ),
   /AppBundle/Entity/EntityThree  ( ... ),
   /AppBundle/Entity/EntityOne ( ... ),
  )
  </code></pre>
  
  <p>I would expect, or like to have a multi dimensional array:</p>
  
  <pre><code>Array(
  [0] =&gt; Array(
    [0] /AppBundle/Entity/EntityOne,
    [1] /AppBundle/Entity/EntityTwo,
    [2] /AppBundle/Entity/EntityThree
    ),
  [1] =&gt; . . . 
  )
  </code></pre>
  
  <p>The results are not related by row. Nor are they in any predictable order that I can group them by with <code>array_chunk()</code></p>
  
  <p>The generated sql runs fine. The DQL returns accurate results -- they're just not formulated in a way that I would expect. I am following Doctrines (elusive) documentation on eager loading joins:</p>
  
  <p><a href="http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html" rel="nofollow noreferrer">http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html</a></p>
  
  <p>This question is very similar to </p>
  
  <p><a href="https://stackoverflow.com/questions/27175873/doctrine-dql-returns-multiple-types-of-entities">Doctrine DQL returns multiple types of entities</a></p>
  
  <p>But my select order is different as my join tables are many-to-many.
  Much thanks!</p>
  
  <p>A variant of this question was asked: </p>
  
  <p><a href="https://stackoverflow.com/questions/37545979/getting-doctrine-dql-results-the-sql-way?rq=1">Getting Doctrine DQL results the SQL way</a></p>
  
  <p>I'm pretty surprised that doctrine does not support eager loading via join table.</p>