在教义2中的日期之间选择条目
2022-08-30 09:27:15
我会发疯这个最小的错误,我没有得到修复。我想在两天之间选择条目,下面的例子说明了我所有的失败:
选项 1.
$qb->where('e.fecha > ' . $monday->format('Y-m-d'));
$qb->andWhere('e.fecha < ' . $sunday->format('Y-m-d'));
结果(0 个条目):
SELECT r0_.id_reservacion AS id_reservacion0, r0_.fecha AS fecha1, r0_.cliente AS cliente2
FROM reservacion r0_
WHERE (r0_.fecha > 2012 - 07 - 16) AND (r0_.fecha < 2012 - 07 - 22)
选项 2
$qb->add('where', 'e.fecha between 2012-01-01 and 2012-10-10');
结果(0 个条目):
SELECT r0_.id_reservacion AS id_reservacion0, r0_.fecha AS fecha1, r0_.cliente AS cliente2
FROM reservacion r0_ WHERE r0_.fecha
BETWEEN 2012 - 01 - 01 AND 2012 - 10 - 10
这是我的当前条目的表:
id fecha cliente
1 2012-07-16 00:00:00 2
2 2012-07-16 13:00:00 4
3 2012-07-22 23:00:00 4
编辑 1
为了评估sql以避免疑问,我运行了以下查询:
$qb->where('e.fecha > ' . $sunday->format('Y-m-d'));
结果(3 个条目):
SELECT r0_.id_reservacion AS id_reservacion0, r0_.fecha AS fecha1, r0_.cliente AS cliente2
所以,看起来sql不是问题所在。从保留r0_ WHERE r0_.fecha > 2012 - 07