Something like this should work...

        public function view($id = null) {

                ............

                $video = $this->Video->find('first', array(
                        'recursive' => -1,
                        'conditions' => array('Video.id' => $id)
                ));
                $this->set(compact('Video'));

                $this->Video->updateAll(
                        array(
                                'Video.views' => 'Video.views + 1'
                        ),
                        array('Video.id' =>  $video['Video']['id'])
                );

                ...................

Andras Kende
http://www.kende.com

On Jan 16, 2011, at 5:19 PM, [email protected] wrote:

> Hi Guys, ...
> How you all doinnnnnnnn... Have a ???
> How can I display page views,...
> I have a table and a field called "views" and I want it to increment
> by 1 (one) every time is specific page accessed.
> Here is my videos table:
> 
> 
> id    int(11)         UNSIGNED        No              auto_increment
>       user_id int(11)                 Yes     NULL
>       category_id     int(11)                 Yes     NULL
>       name    varchar(120)    latin1_swedish_ci               No
>       description     text    latin1_swedish_ci               Yes     NULL
>       embed_code      text    latin1_swedish_ci               Yes     NULL
>       video_thumb     text    latin1_swedish_ci               Yes     NULL
>       views   int(11)                 No      0
>       comments        int(11)                 No      0
>       last_comment    datetime                        Yes     NULL
>       featured        int(1)          UNSIGNED        No      0
>       privacy int(1)          UNSIGNED        No      0
>       created datetime                        No      0000-00-00 00:00:00
>       favorites       int(1)          UNSIGNED        No      0
>       spotlights
> 
> 
> Thanks
> Chris
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to