php - Doctrine - 查询字段日期比较
问题描述
我在定义查询时遇到问题。它返回一个空结果。
因此,我尝试编写一个查询,如果数据库字段lastVerification
(DateTime 字段)晚于 90 天,则返回结果。
它总是返回一个空数组结果。
我的“最佳”尝试:
$endDate = (new \DateTime())->modify('-90 days');
$endDate->format('Y-m-d H:i:s');
$result = $this->getUserRepository()
->createQueryBuilder('otp')
->select('otp')
->where('otp.lastOtpVerification IS NOT NULL')
->andWhere("otp.lastOtpVerification >= :end")
->setParameter("end", $endDate)
->getQuery()
->getResult();
解决方案
推荐阅读
- angularjs - 太多可观察的 $scope 变量和函数导致 RangeError
- vba - 添加自定义宏加载项后,如何将其自动添加到工具栏/功能区?
- java - 初始化数组列表的时间复杂度
- r - 删除仅在某些行中具有 NA 的组
- sql - 异常值检测,排除异常值?
- python - 将字典数据附加到python中的列表时输出更改
- listview - Xamarin Listview:跨越多个项目的框架?
- nlp - Dialogflow:代理名称(项目 ID)- 允许使用哪些字符?
- javascript - 使用Highcharts在折线图中的2点之间画一条线?
- google-code-prettify - 如何使用谷歌代码美化来显示差异