Skip to content Skip to sidebar Skip to footer

Doctrine 2.0 Nativequery Resultsetmapping For Count(id)

I generate an SQL from NativeQuery and this is the result sql: SELECT COUNT(id) AS tot,created_at FROM property WHERE created_at BETWEEN '20120501000000' AND '20120521235959' GR

Solution 1:

I would try:

$rsm->addFieldResult('p', 'tot', 'tot');

as your column as been renamed with COUNT(id) AS tot. If remove the tot alias you can use your original code:

$rsm->addFieldResult('p', 'COUNT(id)', 'tot');

Post a Comment for "Doctrine 2.0 Nativequery Resultsetmapping For Count(id)"