我在MySQL中有一个很好的查询,但是在Symfony2中(当使用命名空间设置时)它不起作用。任何人都可以告诉我为什么?
以下是我收到的错误:[语义错误]第0行,第61行附近'(':错误:类'('未定义。
$query = $em->createQuery("
SELECT q1.sumQty, q2.totalRows
FROM(
SELECT sum(fbaoh.qty) as sumQty
FROM WIC\APIBundle\Entity\FBAOrderHistory fbaoh
WHERE fbaoh.asin = :asin
AND fbaoh.sku = :sku
AND fbaoh.webServiceAccountAmazon = :wsaa
AND fbaoh.datetimePlaced BETWEEN :startDate AND :endDate)
q1,
(
SELECT count(fbai.id) as totalRows
FROM WIC\APIBundle\Entity\FBAInventory fbai
LEFT JOIN WIC\APIBundle\Entity\FBAInventoryReport fbair
WITH fbai.fbaInventoryReport = fbair.id
WHERE fbai.asin = :asin
AND fbai.sku = :sku
AND fbai.webServiceAccountAmazon = :wsaa
AND fbair.report_datetime BETWEEN :startDate AND :endDate)
q2
");
$query->setParameters(array(
'startDate' => $startDate->format('Y-m-d'),
'endDate' => $endDate->format('Y-m-d'),
'wsaa' => $webService,
'sku' => $sku,
'asin' => $asin,
));
$fbaiDataElements = $query->getArrayResult();
感谢。