2011-06-07 35 views
0

我在我的countries表上有一個字段member_count在cakephp - 我可以counterCache相關模型?例如:用戶 - >配置文件

Profile屬於關聯Country

counterCache => 'member_count', 
counterScope => array('Profile.country => 'US') 

所以,當用戶運行一個節省$this->User->Profile->save($this->data),我想更新counterCacheCountry

可能嗎?

+0

你嘗試了嗎? – mark 2011-06-07 16:37:31

+0

是的,我嘗試了很多不同的方法。 – 2011-06-07 21:34:17

回答

0

巴里它沒有列爲在documentation

一個的hasMany關係的選項,我想你可以緩存與國家的結果,他們的個人資料數量的圖,以節省您的一些性能作爲替代。

0

請再看一眼in the documentation以確保您所做的一切正確。

您的個人資料,型號應該是這樣的:

function Profile extends AppModel { 
    $name = 'Profile'; 
    var $belongsTo = array(
     'Country' => array(
      'counterCache' => 'member_count' 
     ) 
    ); 
} 
相關問題