通过DESC的DateTime -Immutable排序查找最后一个条目
如何在数据库中有最后一个条目? 我想拥有今年的最后一个条目(2022,2023 ...),
我已经用$ YEAR-格式('y')
进行了测试,但是结果始终是[ ]
(空数组)
$column = "numeroDevis";
$year = new DateTimeImmutable('now').
public function findLastEntryFromThisYear($column, $year)
{
return $this->createQueryBuilder('d')
->where('d.createdAt = :year')
->andWhere('d.'.$column.' IS NOT NULL')
->setParameter('year', $year)
->orderBy('d.'.$column , 'DESC')
->setMaxResults(1)
->getQuery()
->getResult()
;
}
How can I have the last entry in my database?
I want to have the last entry from this year (2022,2023...)
I have tested with $year->format('Y')
, but the result is always []
(empty array)
$column = "numeroDevis";
$year = new DateTimeImmutable('now').
public function findLastEntryFromThisYear($column, $year)
{
return $this->createQueryBuilder('d')
->where('d.createdAt = :year')
->andWhere('d.'.$column.' IS NOT NULL')
->setParameter('year', $year)
->orderBy('d.'.$column , 'DESC')
->setMaxResults(1)
->getQuery()
->getResult()
;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论