title: doctrine select in new object
body: <p>I'm trying to select multiples objects in a single array result, but i cant see how to select it ...</p>
  
  <p>Well actually I have this DQL:</p>
  
  <pre><code>    $dql = ' SELECT  obj AS Object1, objExternalRef AS Object2 FROM MyEntity1 AS obj
      INNER JOIN obj.objChild AS objChild
      INNER JOIN MyEntity2 AS objExternalRef WITH objExternalRef.objChild= objChild
  
      WHERE something
      ';
  
      $result = $em-&gt;createQuery($dql)
      -&gt;setParameter( ... )
      -&gt;setHint(\Doctrine\ORM\Query::HINT_FORCE_PARTIAL_LOAD, 1)
      -&gt;getResult();
  </code></pre>
  
  <p>returning this array[ Object1 , Object2, Object1, Object2, ... ]:</p>
  
  <pre><code>  {
      "Object1": {...}
    },
    {
      "Object2": { ...}
    }, 
  </code></pre>
  
  <p>And i would like to encapsule this in a new object containing theses 2 objects like:</p>
  
  <pre><code>{
     "Object1" : { ... },
     "Object2" : { ... }
  },    
  {
     "Object1" : { ... },
     "Object2" : { ... }
  },
  </code></pre>
  
  <p>I think I need to make a select of this select(query) to group theses 2 object in a new object, but i can't figure out how to make it.</p>
  
  <p>I also know that if i just make a for($i = 0; i &lt; sizeof($result); i += 2) i can concat these 2 objs in a new one, but I don't think this is so far a nice fix.</p>
  
  <p>Can someone give-me a light here?</p>