Thiago, a HABTM join table by nature has "disposable" records as used by CakePHP. For example, every time you rebuild how the Tags are linked to Articles or vice-versa, the records from the `articles_tags` table that correspond to entries from Articles and Tags are deleted, that's why we shouldn't keep counters in the `articles_tags` table. It's more feasible to keep count of `articles_tags` records in one (or both) of the HABTM tables since these are more persistent.
So going back to the question, will CakePHP's model be able to detect a `counterCache` configuration on a custom ArticlesTag model class, and save the cached counts in `articles` and `tags`? Cheers, OJ On Jan 11, 2012, at 1:40 PM, Thiago Belem wrote: > If you have one record for every association, does make sense to have a > counter there? The counter should be on each table. > > -- > Thiago Belem, > Desenvolvedor WEB > > Enviado do meu Android > > Em 11/01/2012 02:41, "O.J. Tibi" <[email protected]> escreveu: > Hi folks, > > I was just wondering, if it's possible to create a custom Model class for my > HABTM join table, and add `counterCache` to its belongsTo associations. > > If I did something like above and relied on the Model::save() method (for > example, calling Article->save() where the Article HABTM Tags), will the > `articles_tags.article_count` and `articles_tags.tag_count` fields be updated? > > TIA, > OJ > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
