I've seen people do this and I've never understood it.... How are we setting
Item->id THEN reading???

What I've always done is:

$this->Item->recursive = 0;
$itemViewed = $this->Item->read(null, $idItem;);
$updatedViews = $itemViewed['Item']['views'] + 1;
// Why do we need this if we're using saveField?
// $itemViewed['Item']['views'] = $updatedViews;
$itemViewed['Item']['views']++;
$this->Item->saveField("views" $updatedViews);
$this->set('item', $itemViewed);


On Mon, Apr 7, 2008 at 8:41 AM, VisionIzoizo <[EMAIL PROTECTED]>
wrote:

>
> Hi, I've got a problem here, and it's driving me nuts!
>
> Everytime I run this code, a blank row is created in the 'items' DB
> table. The 'items' id field is set to auto_increment. And there are
> also some validation rules set in the model, but in this case, they
> won't work:
>
>                $this->Item->recursive = 0;
>                $this->Item->id = $idItem;
>                $itemViewed = $this->Item->read();
>                $updatedViews = $itemViewed['Item']['views'] + 1;
>                $itemViewed['Item']['views'] = $updatedViews;
>                $this->Item->saveField("views", $updatedViews);
>                $this->set('item', $itemViewed);
>
> Please, someone help me, it's a very strange issue.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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