INTERVAL 1 MONTH not working With symfony2 doctrine?

前端 未结 2 2118
伪装坚强ぢ
伪装坚强ぢ 2021-02-15 18:54

I am stuck here and i spend last 2 days resolving this issue but failed. I am writing a query inside my repository to get the entries for current month. here is my query:-

2条回答
  •  南笙
    南笙 (楼主)
    2021-02-15 19:21

    You should use parameter binding:

    $query = $em->createQuery('SELECT count(a) FROM CollegeStudentBundle:StudentAttendance a where a.student_id = :id and a.date > :date');
    $query->setParameter('id', $id);
    $query->setParameter('date', new \DateTime('-1 month'));
    

提交回复
热议问题