蛋糕PHP计数不同 [英] Cake php count distinct

查看:58
本文介绍了蛋糕PHP计数不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使Cakephp查询的计数不同?

How can this Cakephp query be made to count distinct?

        $matches = $this->Product->find('count', array(
            'conditions' => array(
                "Product.brand_id" => $brand['Brand']['id'],
                'Product.active' => 1

        ));


推荐答案

是这样吗?

$matches = $this->Product->find('count', array(
    'fields' => 'DISTINCT Product.brand_id',
    'conditions' => array("Product.brand_id" => $brand['Brand']['id'],
            'Product.active' => 1)
    ));

这篇关于蛋糕PHP计数不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆