Cakephp 蛋糕计数不同
如何使这个Cakephp查询计数不同Cakephp 蛋糕计数不同,cakephp,Cakephp,如何使这个Cakephp查询计数不同 $matches = $this->Product->find('count', array( 'conditions' => array( "Product.brand_id" => $brand['Brand']['id'], 'Product.active' => 1 )); 像这样的 $matche
$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)
));
我建议在这里使用虚拟字段。和一个分组声明。