如标题所示,我如何获得此查询的结果:
$query = $repository->createQueryBuilder('p')
->where('p.sellDate > '.$startDate->format('Y/m/d'))
->andWhere('p.sellDate < '.$endDate->format('Y/m/d'))
->getQuery();
目前没有给出结果。我已多次更改此代码但未获得当前结果。
答案 0 :(得分:1)
正如@geoB建议的那样,只有这个答案:
$repository = $this->getDoctrine()
->getRepository('AppBundle:Entity');
$query = $repository->createQueryBuilder('p')
->where('p.sellDate > :startDate')
->andWhere('p.sellDate < :endDate')
->setParameter('startDate', $startDate)
->setParameter('endDate', $endDate)
->getQuery()
;
$sells = $query->getResult();
答案 1 :(得分:1)
让Doctrine用以下内容整理日期对象:
$query = $repository->createQueryBuilder('p')
->where('p.sellDate > :startDate')
->andWhere('p.sellDate < :endDate')
->setParameter('startDate', $startDate)
->setParameter('endDate', $endDate)
->getQuery()
;
$sells = $query->getResult();