See, I tried setting recursive to -1 and that didn't helped me either.
See I can implement a behavior which would increment a given field.
But this is a simplistic example of what I want to do. I will try
raising a ticket to see whether this is expected behavior!.
On May 10, 8:56 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> Try $this->Article->recursive = -1;
>
> But you could avoid having to update the field by instead selecting
> from a sequence nextval('page_views') . If you can figure out how to
> associate Article with something like a PageView model built around a
> sequence.
>
> I don't know if this is common or impossible with Cake, but it would
> avoid the update. I'm also thinking of postgres; not sure what the
> mysql way to do this is.
>
> On Sat, May 10, 2008 at 6:52 PM, Ketan Patel <[EMAIL PROTECTED]> wrote:
>
> > I am using Beta: 1.2.0.6311. I have a Article Table which is having
> > associations with other tables like Category, Tags and User.
>
> > I have a view counter in Article Table which would increment the
> > counter each time the article is viewed. I am using the Restrict
> > Behavior by Mariano. This is what I do in the article view controller
> > action.
>
> > $this->Article->restrict();
> > $this->data = $this->Article->findById($id);
> > $this->Article->restrict();
> > $views = $this->data['Article']['views'] + 1;
>
> > $this->Article->id = $this->data['Article']['id'];
>
> > $this->Article->saveField('views', $views);
>
> > This code does update the views but I am not sure why I get all the
> > join statements in the UPDATE Sql statement? The following is the SQL
> > statement issued to update only one field in Article.
>
> > UPDATE `articles` AS `Article` LEFT JOIN `tags` AS `Tag` ON
> > (`Tag`.`articles_id` = `Article`.`id`) LEFT JOIN `categories` AS
> > `Category` ON (`Article`.`categories_id` = `Category`.`id`) SET
> > `Article`.`views` = 646 WHERE `Article`.`id` IN (618)
>
> > I am removing all the associations using 'restrict'. However, I have
> > found a function _getJoins($model) in the dbo_source.php which is
> > called explicity for all 'updates' and 'delete' calls. This is where
> > the extra join statements are coming from. The above code does what is
> > expected to do, but its adding this extra join statements which
> > shouldn't be there if one removes the associations.
>
> > What do you guys have to say?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---