0

I have a field member_count on my countries table.

Profile belongsTo Country

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

So, when a user runs a save on $this->User->Profile->save( $this->data), i would like to update the counterCache in Country.

Possible?

martynthewolf
  • 1,718
  • 2
  • 11
  • 22
Barry Chapman
  • 6,690
  • 3
  • 36
  • 64

2 Answers2

0

Barry its not listed as an option on a hasMany relationship in the documentation

I suppose you could cache a view with the results of the countries and their number of profiles to save you some performance as an alternative.

Leo
  • 1,521
  • 12
  • 18
0

Please have another look in the documentation to make sure, you did everything right.

Your Profile-Model should look like this:

function Profile extends AppModel {
    $name = 'Profile';
    var $belongsTo = array(
        'Country' => array(
            'counterCache' => 'member_count'
        )
    );
}
Tim
  • 5,893
  • 3
  • 35
  • 64