Doctrine -- 拥有带查询生成器的 MAX
Doctrine -- Having MAX with query builder
我正在尝试使用查询生成器进行此查询:
SELECT * FROM my_table
WHERE code_response <> 0
GROUP BY order_id
HAVING MAX(last_date_run)
但我没有找到如何使用查询生成器执行 HAVING MAX:
我这样做了:
return $this->createQueryBuilder('i')
->where('i.codeResponse != :codeError')
->groupBy('i.order')
->having('lastDateRun');
}
如何使用查询生成器进行 HAVING MAX?
这个
$qb = $this->createQueryBuilder('i');
return $this
->createQueryBuilder('i')
->where('i.codeResponse != :codeError')
->groupBy('i.order')
->having($qb->expr()->max('i.lastDateRun'));
应该可以,但我没有测试
我正在尝试使用查询生成器进行此查询:
SELECT * FROM my_table
WHERE code_response <> 0
GROUP BY order_id
HAVING MAX(last_date_run)
但我没有找到如何使用查询生成器执行 HAVING MAX:
我这样做了:
return $this->createQueryBuilder('i')
->where('i.codeResponse != :codeError')
->groupBy('i.order')
->having('lastDateRun');
}
如何使用查询生成器进行 HAVING MAX?
这个
$qb = $this->createQueryBuilder('i');
return $this
->createQueryBuilder('i')
->where('i.codeResponse != :codeError')
->groupBy('i.order')
->having($qb->expr()->max('i.lastDateRun'));
应该可以,但我没有测试