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.
Solutions:
1. You can check the value before update.
2. You can set unique index wait for error and handle it.
3. You can use database trigger. (My preferred solution )


On Mon, Mar 7, 2011 at 1:43 PM, Krissy Masters
<[email protected]>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'] ) );
>
> K
>
> From: [email protected] [mailto:[email protected]] On
> Behalf
> Of Zaky Katalan-Ezra
> Sent: Monday, March 07, 2011 5:04 AM
> To: [email protected]
> Cc: Zachary Stenger
> Subject: Re: Database question
>
> Use some GUI to manage your database.
> Mysql workbench is a good choice.
>
> Check the AI column in Alter table form.
> --
> 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
>
> --
> 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
>



-- 
Regards,
Zaky Katalan-Ezra
QA Administrator
www.IGeneriX.com
Sites.IGeneriX.com
054-7762312

-- 
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

Reply via email to