title: How to get a Collection in Doctrine2's query results
body: <p>I am trying to execute a query using doctrine2 and need it to return a collection object.</p>
  
  <p>Simplified snippet:</p>
  
  <pre><code>$players = $this-&gt;getEntityManager()
      -&gt;createQueryBuilder()
      -&gt;select('p')
      -&gt;from('...\Player', 'p')
      -&gt;getQuery()
      -&gt;getResult();
  </code></pre>
  
  <p>The returned object is an array of Player.</p>
  
  <p>The information on <a href="http://www.doctrine-project.org/docs/orm/2.0/en/reference/dql-doctrine-query-language.html#query-result-formats" rel="noreferrer">query result formats</a> says:</p>
  
  <blockquote>
    <p>The result is either a plain collection of objects (pure) or an array where the objects are nested in the result rows (mixed).</p>
  </blockquote>
  
  <p>On what does the result type depend and how can I achieve getting a collection object?</p>