0

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?

4

1 回答 1

1

您正在写作qroup而不是group(那是q代替g)。这就是为什么它不起作用。

P.S.: get some sleep...

于 2012-04-23T09:20:46.383 回答