我想用doctrine查询构建器
运行该查询select * from stats group by MINUTE(date_time)
我试过这个查询构建器但抛出了异常
[语义错误]第0行,col 50接近'MINUTE(s.dateT':错误:无法按未定义的标识或结果变量进行分组。
$queryBuilder =
$entityManager->createQueryBuilder('Application\Entity\Stats');
$queryBuilder->select('s')
->from('Application\Entity\Stats', 's');
$queryBuilder->groupBy('MINUTE(dateTime)');
我如何用分钟分组
答案 0 :(得分:0)
错误显示您无法按结果分组。如果你可以用行SQL来做,那就试试这个
$conn = $entityManager->getConnection();
$sql = "SELECT *, MINUTE(row.date) as m FROM `table` AS row GROUB BY m"
$query = $conn->prepare($sql);
$query->execute;
$query->fetchAll();