蛋糕php数量不同

时间:2013-12-02 16:05:35

标签: cakephp

如何对这个Cakephp查询进行计数?

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

        ));

1 个答案:

答案 0 :(得分:5)

这样的东西?

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