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
Post a Comment