我正在尝试获取每个商店的评论数,并且我真的停留在这一步。
有可能做到吗,怎么做?
public function display()
{
$this->loadModel('Shops');
$shoplist=$this->Shops->find('all')->order(['title' => 'DESC', 'id' => 'ASC'])->contain([
'Comments' => function ($q) {
return $q->select('id')->where(['published' => 1])->count();
}]);;
$this->set('shoplist', $shoplist );
}