I am trying to execute a query using doctrine2 and need it to return a collection object.
Simplified snippet:
$players = $this->getEntityManager()
The getResult() always returns an array. If you want a collection, you must pass the array that is returned by getResult() to Doctrine's ArrayCollection
e.g.
use Doctrine\Common\Collections\ArrayCollection;
$result = $this
->getEntityManager()
->createQueryBuilder()
->select('p')
->from('...\Player', 'p')
->getQuery()
->getResult()
;
$players = new ArrayCollection($result);