我从学说中获取数据有两个问题:
如何编写Doctrine查询以执行与in Mysql
相同的操作这是我的存储库中的不完整代码?
public function findByYearlyAttendanceTillToday($id)
{
$em = $this->getEntityManager();
$query = $em->createQuery("SELECT count(a) FROM CollegeStudentBundle:StudentAttendance a where a.present LIKE 'A' and a.student_id = :id and a.date > :date");
$query->setParameter('id', $id);
$query->setParameter('date', **?????**);
return $query->getResult();
}
答案 0 :(得分:8)
以下是您的需求:
new \DateTime('midnight first day of this month');
new \DateTime('first day of january');
我也会改变这个:
a.date > :date
到此:
a.date >= :date