【发布时间】:2015-10-21 14:54:34
【问题描述】:
我正在使用 symfony 框架开发 Web 应用程序。我想从所有月份的数据库中获取记录。我不知道如何编写查询以获取从 1 月到 12 月的记录。 这是我的代码:
$totalSearchesByAdminMonth = $em->createQueryBuilder()
->select('count(SearchHistory.id) AS totalSearchesByAdmin')
->from('DRPAdminBundle:Log', 'SearchHistory')
->where('SearchHistory.last_updated like :last_updated')
->setParameter('last_updated',$months.'-%')
->andwhere('SearchHistory.event = :event')
->setParameter('event','ADMIN_SEARCH')
->getQuery()
->getArrayResult();
请帮忙。
【问题讨论】: