Hi, thanks for replying:

I did write the code just the way you did before, but I had the same
bug. Actually, the view is rendered perfectly, the way I wrote my code
is not the problem. Don't mind about the code, I found a weird
solution, and it's definitely a CakePhp bug. I found a guy that had
the same problem, it seems to happen in Firefox, though I'm not 100%
sure about this. This is the Google cached page: (The original link
seems to be broken)

http://64.233.167.104/search?q=cache:USFkqlLTlAYJ:nathan.ashleafmedia.com/2008/an-adventure-with-cakephps-savefield/+cakephp+saveField+issue+in+firefox&hl=es&strip=1

You see, I used to call my action with the classical 'items/viewItem/
idItem', but in this case, cake or mySQL seem to freak out and execute
random DB saves. I 'solved' the problem just by calling my action with
this link:

'items/viewItem/idItem/'

That's it, that's all it took to fix the bug, though I really don't
like it, I don't trust hacks.

Anyways, thanks a lot for replying.

On Apr 7, 1:50 pm, Baz <[EMAIL PROTECTED]> wrote:
> 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