我正在尝试从我的Symfony2项目中查询模型,但我无法将通配符替换为我的DQL查询。看;
$q2 =
'SELECT
p.codigo,
p.descripcion,
SUM(l.cantidad) as cantidad,
SUM(l.cantidad*l.pvp) as euros
FROM
MGFAppBundle:LineaVenta l
JOIN
MGFAppBundle:Producto p
WITH
l.producto = p.id
JOIN
l.venta v
WITH
l.venta = v.id
WHERE
l.producto IN (:array)
AND
v.farmacia = :farmacia
GROUP BY
p.codigo';
$query2 = $this->em->createQuery($q2)
->setParameter('farmacia', $farmacia)->setParameter('array', $array);
$porFarmacia = $query2->getResult();
// This does not return a single value, when it should return 2 lines.
echo $query2->getSQL();
// Returns:
// SELECT p0_.codigo AS codigo0, p0_.descripcion AS descripcion1, SUM(l1_.cantidad) AS sclr2, SUM(l1_.cantidad * l1_.pvp) AS sclr3 FROM LineaVenta l1_ INNER JOIN Producto p0_ ON (l1_.lineaventas_id = p0_.id) INNER JOIN Venta v2_ ON l1_.venta_id = v2_.id AND (l1_.venta_id = v2_.id) WHERE l1_.lineaventas_id IN (?) AND v2_.farmacia_id = ? GROUP BY p0_.codigo
所以,问号应该是参数。任何提示?提前谢谢。