Nick, that code has a race condition. Two different users looking at the page
at the same time could cause the count to be incremented by only one total,
when you want the count to be incremented by one for each user.
The method Krissy showed is atomic and does not have this problem.
On Mar 12, 2011, at 11:28, nurvzy wrote:
> $this->Product->id = 40;
> $this->Product->saveField('vote', $this->Product->field('vote') + 1);
>
> Nick
>
> On Mar 12, 9:36 am, Krissy Masters wrote:
>> $this->Product->updateAll(array('Product.vote'=>'Product.vote+1'),
>> array('Product.id'=>40));
--
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