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 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? > > > 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 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 Outfit > > >>>http://www.classoutfit.com > > >>> On 6 Jul 2011, at 17:17, euromark wrote: > > >>>> 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 > > >>>>http://bakery.cakephp.org/articles/danaki/2009/05/29/counter-cache-be... > >>>>http://bakery.cakephp.org/articles/dericknwq/2007/05/02/countercache-... > >>>>http://www.neilcrookes.com/2010/01/09/cakephp-treecountercachebehavio... > >>>> and probably some more > > >>>> On 6 Jul., 17:46, Jeremy Burns | Class Outfit > >>>> <jeremybu...@classoutfit.com> wrote: > >>>>> 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, wiseguysonly wrote: > > >>>>>> One of my early CakePHP sites has come back to haunt me. I need > >>>>>> to add > >>>>>> a counterCache to a pre-existing hasMany relationship. > > >>>>>> Does there exist a method to set up the counterCache with > >>>>>> current > >>>>>> counts field once I have have created it? > > >>>>>> Thanks in advance, > > >>>>>> Tim > > >>>>>> -- > >>>>>> Our newest site for the community: CakePHP Video > >>>>>> Tutorialshttp://tv.cakephp.org > >>>>>> Check out the new CakePHP Questions > >>>>>> sitehttp://ask.cakephp.organdhelpothers with their CakePHP > >>>>>> related questions. > > >>>>>> To unsubscribe from this group, send email to > >>>>>> cake-php+unsubscr...@googlegroups.com For more options, visit > >>>>>> this group athttp://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 sitehttp://ask.cakephp.organd > >>>> help others with their CakePHP related questions. > > >>>> To unsubscribe from this group, send email to > >>>> cake-php+unsubscr...@googlegroups.com For more options, visit this > >>>> group athttp://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 sitehttp://ask.cakephp.organd > >>> help others with their CakePHP related questions. > > >>> To unsubscribe from this group, send email to > >>> cake-php+unsubscr...@googlegroups.com For more options, visit this > >>> group athttp://groups.google.com/group/cake-php > > > -- > > Our newest site for the community: CakePHP Video > > Tutorialshttp://tv.cakephp.org > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help > > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php