I've got the following query:
<?php $em = $this->getDoctrine()->getManager(); $data['ps'] = $em->createQuery('SELECT s,ps FROM AppBundle:Sucursales s LEFT JOIN AppBundle:ComprasProductosSucursales ps WITH s.id = ps.sucursal')->getResult(); But I get a result like in the following image:
![Example of Doctrine2 resultset][1]
I expected that $data['ps'][1] to be part of $data['ps'][0], otherwise the iteration of the array is going to be very weird.
So, it's possible to get the result of the joined table AppBundle:ComprasProductosSucursales as columns of the AppBundle:Sucursales data?
ORMs:
AppBundle\Entity\Sucursales: type: entity table: sucursales # Note: no relations defined, deleting the rest of the columns for clarity AppBundle\Entity\ComprasProductosSucursales: type: entity table: compras_productos_sucursales manyToOne: producto: targetEntity: ComprasProductos sucursal: targetEntity: Sucursales cascade: { }
SELECT s0_.id AS id0, s0_.nombre AS nombre1, s0_.telefono AS telefono2, s0_.direccion AS direccion3, s0_.activo AS activo4, c1_.id AS id5, c1_.cantidad_promedio AS cantidad_promedio6, c1_.producto_id AS producto_id7, c1_.sucursal_id AS sucursal_id8 FROM sucursales s0_ LEFT JOIN compras_productos_sucursales c1_ ON (s0_.id = c1_.sucursal_id)