I have a simple model where I would like to find some count data per date. I made this find in order to do that:
$statsubscriptions = $this->Nlist->Statsubscription->find('all',
array(
'fields'=>array('Statsubscription.date','Statsubscription.type','COUNT(*) as qs'),
'qroup'=>array('Statsubscription.date','Statsubscription.type'),
'conditions'=>array('Statsubscription.nlist_id'=>$id),
'recursive'=>-1,
)
);
But it does not work. The generated query is the following:
SELECT `Statsubscription`.`date`, `Statsubscription`.`type`, COUNT(*) as qs
FROM `statsubscriptions` AS `Statsubscription`
WHERE `Statsubscription`.`nlist_id` = 1
GROUP BY is completly missing... Instead of the above I would like this query to be generated:
SELECT `Statsubscription`.`date`, `Statsubscription`.`type`, COUNT(`Statsubscription`.`id`) as qs
FROM `statsubscriptions` AS `Statsubscription`
WHERE `Statsubscription`.`nlist_id` = 1
GROUP BY `Statsubscription`.`date`, `Statsubscription`.`type`
How can I achieve this? And what could be the reason of the missing GROUP BY?