Doctrine won't let me select specific fields Doctrine won't let me select specific fields symfony symfony

Doctrine won't let me select specific fields


From the documentation on "Partial Object Syntax":

By default when you run a DQL query in Doctrine and select only a subset of the fields for a given entity, you do not receive objects back. Instead, you receive only arrays as a flat rectangular result set, similar to how you would if you were just using SQL directly and joining some data.

If you want to select partial objects you can use the partial DQL keyword.

php console doctrine:query:dql --hydrate array \  'SELECT partial s.{name ,id}, partial c.{name, id }    FROM DatabaseBundle:ProductCategories c    JOIN c.suppliers s ORDER BY s.name, c.name'