Re: Retrograde counterCache

2011-07-06 Thread Jeremy Burns | Class Outfit
In my experience you need to do it with a simple SQL query at the db level. I am not aware of any Cake magic. If it's a continuous problem worthy of some dev time you could write a simple behaviour to do it. Jeremy Burns Class Outfit http://www.classoutfit.com On 6 Jul 2011, at 16:43,

Re: Retrograde counterCache

2011-07-06 Thread euromark
there are already several different counterCache solutions available one in the core see the cookbook or http://stackoverflow.com/questions/1351823/countercache-in-cake-php and several als plugins etc depends on what exactly you need

Re: Retrograde counterCache

2011-07-06 Thread Jeremy Burns | Class Outfit
Doesn't his question relate to populating the counterCache fields with the right values on creation, rather than maintaining it? Jeremy Burns Class Outfit http://www.classoutfit.com On 6 Jul 2011, at 17:17, euromark wrote: there are already several different counterCache solutions available

Re: Retrograde counterCache

2011-07-06 Thread Thomas Ploch
Wouldn't a simple find('all') saveAll() script do the trick? Am Mittwoch, den 06.07.2011, 18:29 +0100 schrieb Jeremy Burns | Class Outfit: Doesn't his question relate to populating the counterCache fields with the right values on creation, rather than maintaining it? Jeremy Burns Class

Re: Retrograde counterCache

2011-07-06 Thread Miles J
Well, do you need to populate it right off the bat? Cake will automatically insert the correct counter value the next time a save or delete is made (all it does is a findCount()). On Jul 6, 10:38 am, Thomas Ploch profipl...@googlemail.com wrote: Wouldn't a simple find('all') saveAll() script do

Re: Retrograde counterCache

2011-07-06 Thread Jeremy Burns | Class Outfit
I think he's adding it to existing tables, so it won't start from zero. He needs to do a find count group by and update the new counterCache field. Jeremy Burns Class Outfit http://www.classoutfit.com On 6 Jul 2011, at 20:21, Miles J wrote: Well, do you need to populate it right off the bat?

Re: Retrograde counterCache

2011-07-06 Thread Miles J
In that case, just create a shell that loops over everything, runs count queries, and then saves the counter cache value. On Jul 6, 1:11 pm, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: I think he's adding it to existing tables, so it won't start from zero. He needs to do a

Re: Retrograde counterCache

2011-07-06 Thread euromark
well of course you have to trigger it somehow but you can simply invoke that for every record (shell, admin action). some behaviors (i remember this from geocoder et cetera) even have an own updateAll method which does extacly that. if not, invent it for yours :) On 6 Jul., 22:58, Miles J

Re: Retrograde counterCache

2011-07-06 Thread euromark
and most of the sluggable behaviors I know do provide a similar method (of course^^ if you change the way the behavior works you need to trigger the updateAll) simply copy and paste it On 6 Jul., 23:26, euromark dereurom...@googlemail.com wrote: well of course you have to trigger it somehow but