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 - Unable to make sub reports with Jasper -

scala - play framework: Modules were resolved with conflicting cross-version suffixes -

Save and close a word document by giving a name in R -