我生成NativeQuery的SQL,这是结果的SQL:
SELECT COUNT(号),TOT,created_at来自物业WHERE created_at '之间的201205.01亿' 与 '20120521235959' GROUP BY YEAR(created_at),MONTH(created_at),日(created_at);
这是我的ResultSetMapping:
$rsm = new \Doctrine\ORM\Query\ResultSetMapping;
$rsm->addEntityResult('Entity\Property', 'p');
$rsm->addFieldResult('p','count(id)','tot'); // <-- this don't work
$rsm->addFieldResult('p','created_at','created_at');
直接运行在MySQL上面的查询结果是OK:
tot created_at
11 2012-05-02 11:23:25
11 2012-05-08 14:56:40
152 2012-05-16 14:43:46
5 2012-05-17 16:26:31
29 2012-05-18 14:55:33
但结果阵列的TOT别名不存在!
问题是:
如何我设置正确ResultSetMapping的计数(ID)?