Good point. The updateAll method probably does load of uneccessary left joins... I'll probably switch to a custom query as since it's an update, there's no caching involved, so no speed to be gained by using Cake's built in methods.
On Jun 24, 9:27 pm, Miles J <[email protected]> wrote: > You could write it like that, but a custom is just simpler and > faster :p > > On Jun 24, 12:15 pm, Rangi <[email protected]> wrote: > > > Thanks for all the replies everyone. > > > I think I'm going to go with the updateAll method: > > > $this->Product->updateAll(array('Product.vote'=>'Product.vote+1'), > > array('Product.id'=>40)); > > > On Jun 24, 5:07 pm, brian <[email protected]> wrote: > > > > On Wed, Jun 24, 2009 at 3:35 AM, Rangi<[email protected]> wrote: > > > > > Hello, > > > > > I've searched the manual and this group for an answer to this but > > > > can't find anything, so wondering if anyone can help. > > > > > I'd like to do a query like this: > > > > > UPDATE product SET num_ratings = num_ratings + 1; > > > > > In CakePHP I can't figure out how to do it in less than 2 queries > > > > (load record to look up num_ratings, increment num_ratings in php, > > > > save record). > > > > > Should I just use a custom query for this? > > > > See > > > here:http://teknoid.wordpress.com/2008/05/22/incrementing-a-field-in-cakephp/ > > > > Also, check out IncrementBehavior > > > >http://bakery.cakephp.org/articles/view/increment-behavior --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
