[email protected]
[Top] [All Lists]

Re: Database question

Subject: Re: Database question
From: Ryan Schmidt
Date: Mon, 7 Mar 2011 12:50:45 -0600
On Mar 7, 2011, at 12:34, Zaky Katalan-Ezra wrote:
> On Mon, Mar 7, 2011 at 1:43 PM, Krissy Masters wrote:
>> Since only 1 field can be auto-inc, that’s not really the best solution.
>> I would suggest to update 1 field where CONDITION
>> In the view function add in something like:
>> $this->Model->updateAll( array( 'Post.view_count' => 'Post.view_count + 1'
>> ), array( 'Post.id' => $post['Post']['id'] ) );
> This solution raise another issue.
> If two users get the data at the same time but update the data one after 
> another you end up with equal value in two rows.

I don't think that problem exists here. Using updateAll() should generate a 
single UPDATE SQL statement, which should be atomic.

Our newest site for the community: CakePHP Video Tutorials 
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 

<Prev in Thread] Current Thread [Next in Thread>