Cakephp 蛋糕计数不同

Cakephp 蛋糕计数不同,cakephp,Cakephp,如何使这个Cakephp查询计数不同 $matches = $this->Product->find('count', array( 'conditions' => array( "Product.brand_id" => $brand['Brand']['id'], 'Product.active' => 1 )); 像这样的 $matche

如何使这个Cakephp查询计数不同

        $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)
    ));

我建议在这里使用虚拟字段。和一个分组声明。