I have never used this behavior, but my guess is that restrict()
requires you to pass on some parameters. Please confirm, I guess that
would help.

On May 11, 3:52 am, 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to