【问题标题】:Cakephp, group by - count function is returning nullCakephp,group by - count 函数返回 null
【发布时间】:2014-04-26 23:40:27
【问题描述】:

我有下一条声明:

$lead_count = $this->Lead->find("list", array("conditions" => array("chosen_country_id" => $countries, "lead_type" => "Consumer"), 
                                                    "fields" => array('Lead.status', 'count(Lead.id)'),
                                                    "group" => "Lead.status"));

这个语句形成的查询是:

SELECT "Lead"."status" AS "Lead__status", count("Lead"."id") 
FROM "public"."leads" AS "Lead" 
WHERE chosen_country_id IN (167, 201, 203, 39) AND "lead_type" = 'Consumer' 
GROUP BY "Lead"."status"

如果我在我的数据库上手动运行此查询,结果是:

    Lead__status         | count
-----------------------------+-------
 Contacted                   |     1
 Assigned to lead dispatcher |     1
 On call                     |     3
 Sent to Distributor         |     1
 Call attempted 1            |     1
 New                         |   241
 Mark as invalid             |     1

但在我的网页上,结果是:

数组(

'Contacted' => null,
'Assigned to lead dispatcher' => null,
'On call' => null,
'Sent to Distributor' => null,
'Call failed 1' => null,
'New' => null,
'Mark as invalid' => null

)

有什么想法吗?

谢谢

【问题讨论】:

    标签: sql count null group-by cakephp-2.0


    【解决方案1】:

    请从这个帖子中找到你的答案,我认为这是一个微笑的问题..

    CakePHP GROUP and COUNT items returned in list

    【讨论】:

      猜你喜欢
      • 2017-01-24
      • 2011-04-05
      • 1970-01-01
      • 2012-11-20
      • 1970-01-01
      • 2021-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多