FWIW the suggestions made by Ryan & Jeremy are better than using the Model
Query method
as you lose out on the cake auto magic with the method

$this->Video->doIncrement($id);
vs
$this->Video->query('UPDATE fociki_videos' . ' SET views = views +
1' .  ' WHERE id = ' . $video['Video']['id']);

this point might be mute in this case but its worth knowing;
any how the first option is

a) less code
b) clearer
c) does not tie your app to using a table name with prefix

 - S




On 11 February 2011 04:55, [email protected] <[email protected]> wrote:

> Thank You Jeremy,
> I got another approch to it...
> here is what works in my case:
>
>  $this->Video->query('UPDATE fociki_videos' . ' SET views = views +
> 1' .  ' WHERE id = ' . $video['Video']['id']);
>
> Thank You for Your Help guys,...
> I love you with all my heart... LoL
>
> I'm sorry to bother you with all these questions,... I learn on the
> way,... With little or no knowllege of CAKE and PHP I have gone so
> far... Check me out if you what,... and hire me for your next project
> help... LOL Just kidding guys, don't take it siriously...
>
> Thank you All !!
> chris
>
> On Feb 10, 8:39 pm, Jeremy Burns | Class Outfit
> <[email protected]> wrote:
> > Sounds like you need to have a line of code in the controller's view
> method that calls a simple model function:
> >
> > $this->Model->increment($id);
> >
> > In the model:
> >
> > function increment($id) {
> >         $this->updateAll(array('Model.view_count' =>
> 'Model.view_count+1'), array('Model.id' => $id));
> >
> > }
> >
> > Or you could just call it directly from the view method in the
> controller:
> >
> > $this->Model->updateAll(array('Model.view_count' =>
> 'Model.view_count+1'), array('Model.id' => $id));
> >
> > This way, whenever the view method is called (in other words, each time
> the page is rendered) you increment the view_count field by one.
> >
> > Jeremy Burns
> > Class Outfit
> >
> > [email protected]http://www.classoutfit.com
> >
> > On 11 Feb 2011, at 03:31, [email protected] wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi Jeremy,
> > > What I'm looking for is to set the data,... say to set field views in
> > > Video table increment by 1 every time page accessed. To set data,...
> > > NOT to retrive.
> >
> > > Thanks
> > > chris
> >
> > > On Feb 10, 1:11 pm, Jeremy Burns | Class Outfit
> > > <[email protected]> wrote:
> > >> RTFM.http://book.cakephp.org/
> >
> > >> Jeremy Burns
> > >> Class Outfit
> >
> > >> [email protected]http://www.classoutfit.com
> >
> > >> On 10 Feb 2011, at 20:57, [email protected] wrote:
> >
> > >>> Hi Mike,
> > >>> Yes, I know that I have to read from table,...
> > >>> But I don't know how... LOL
> > >>> the code... anyone can help...?
> >
> > >>> Thanks
> > >>> chris
> >
> > >>> On Feb 10, 11:59 am, mike karthauser <[email protected]>
> wrote:
> > >>>> On 10 Feb 2011, at 17:30, "[email protected]" <[email protected]>
> wrote:
> >
> > >>>>> Hi All,
> > >>>>> How u All Doinnn...?!
> >
> > >>>>> Can anyone teach me how to setup views,... so when page is
> > >>>>> accessed ... it will set field views="increment numbers" like Video
> > >>>>> views=906, Group views=489, etc.. like how many time page has been
> > >>>>> accessed.
> >
> > >>>> You won't be doing any counts in the view, rather updating the count
> when the action is called and passing that value to the view.
> >
> > >>>> All you'll need to do is to get a count value from your table and
> then resave it after you have added 1. You may also want to do this as an
> ajax call in JavaScript when you have played say half of the video as then
> it won't be affected if bots hit the page or people refresh loads
> >
> > >>>>> Thanks
> > >>>>> chris
> >
> > >>>>> --
> > >>>>> Our newest site for the community: CakePHP Video Tutorialshttp://
> tv.cakephp.org
> > >>>>> Check out the new CakePHP Questions
> sitehttp://ask.cakephp.organdhelpothers with their CakePHP related
> questions.
> >
> > >>>>> To unsubscribe from this group, send email to
> > >>>>> [email protected] For more options, visit this
> group athttp://groups.google.com/group/cake-php
> >
> > >>> --
> > >>> Our newest site for the community: CakePHP Video Tutorialshttp://
> tv.cakephp.org
> > >>> Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> others with their CakePHP related questions.
> >
> > >>> To unsubscribe from this group, send email to
> > >>> [email protected] For more options, visit this
> group athttp://groups.google.com/group/cake-php
> >
> > > --
> > > Our newest site for the community: CakePHP Video Tutorialshttp://
> tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> others with their CakePHP related questions.
> >
> > > To unsubscribe from this group, send email to
> > > [email protected] For more options, visit this
> group athttp://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
>

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