est*_*ire 1 php archive symfony doctrine-orm
我的学说查询目前在一天内查询边栏中的帖子存档的所有帖子.
问题是当我点击2013年10月(这应该只显示10月的帖子),但是,11月1日,下个月的第1天也被包括在内.
我该如何解决这个问题,以便本月的第一个月不包含在上个月的帖子中?
Doctrine2查询
public function getPostsByMonth($year, $month)
{
// Query for blog posts in each month
$date = new \DateTime("{$year}-{$month}-01");
$toDate = clone $date;
$toDate->modify("first day next month midnight");
$qb = $this->createQueryBuilder('b')
->where('b.created BETWEEN :start AND :end')
->setParameter('start', $date)
->setParameter('end', $toDate)
;
return $qb->getQuery()->getResult();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
338 次 |
| 最近记录: |