In my Symfony2 controller, I have two requests:
as in this example:
$object = $this->getDoctrine()->getManager()
->createQuery('SELECT PARTIAL o.{id,name,field1}
FROM SomeBundle:SomeEntity o
WHERE o.id = :objectId')
->setParameter('objectId', $objectId)
->getResult();
$objects = $this->getDoctrine()->getManager()
->createQuery('SELECT PARTIAL o.{id,name,field1, field2}
FROM SomeBundle:SomeEntity o ')
->getResult();
The effect that I get in the collection $objectsis a collection of objects SomeBundle:SomeEntity, except for the one I got the variable $objectfor which I get the proxy object.
If I output the collection $objects, and for each element I want to print the output, which includes the fields: name, field1, field2, I get null for field2 for this object. In fact, if I get this $objectin any other controller running along with this, field2 is also zero for every object reference.
For example, if I want to display each object as:
name field1 field2
I get the following array for $objects:
nameExample field1Example field2Example
nameExample field1Example field2Example
nameExample field1Example
nameExample field1Example field2Example
nameExample field1Example field2Example
- $object.
2 , getResult . , Entity Request.
.