Monday, November 1, 2010

counterCache not working

I am using 1.3.4 and can not get this to work.

 

Contact model

var $belongsTo = array(

                                'Profile' => array(

                                                'className' => 'Profile',

                                                'foreignKey' => 'profile_id',

                                                'counterCache' => true,

                                )

                );

 

Profile model

var $hasMany = array(

                                'Contact' => array(

                                                'className' => 'Contact',

                                                'foreignKey' => 'profile_id',

                                                'dependent' => false),

…..

 

Profile table has contact_count field INT(10)

 

Any ideas why this will not happen?

 

Side note ** Eventually the Profile table will have 4 model_count fields, if I do manage to get 1 working can the 1 table have more than 1 counted model?

 

Thanks

 

Dave

No comments: