php - CakePHP counterCache with contain -


i have following database structure:

users

id, username, ..., silver_medal_counter, gold_medal_counter, bronze_medal_counter 

badges

id, name, description, points, medal (silver, gold, bronze) 

userbadges

id, user_id, badge_id, created 

if userbadge added, countercache should update relevant medal_counter field in users table.

what have:

class userbadge extends appmodel {      public $belongsto = array(           'user' => array(             'countercache' => array(                 'silver_medal_counter' => array('userbadge.badge.medal' => 'silver'),                 'gold_medal_counter' => array('userbadge.badge.medal' => 'gold'),                 'bronze_medal_counter' => array('userbadge.badge.medal' => 'bronze')             )           ),           'badge' => array('classname' => 'badge')       ); } 

note: $actas = array('containable'); included. using cakephp 2.5.6.

how can solve this?


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -