I don't get it....What does the URL have to do with saveField? How are you populating that $idItem variable? That right there would be your problem.
This is not "definitely a CakePHP bug" unless you can provide more information. Why are we using saveField() in a viewItem anyway? But I digress, your issue is with how you set the ID, it has nothing to do with saveField() (unless you can prove otherwise)... I know you "fixed" it, but you really need to find the deeper issue here or something like this is going to come back and bite you in the but. FYI I've duplicated what you have here, which is a read of a model via the ID on the URL and called saveField() and it works fine, without any need for a trailing slash. On Apr 8, 8:24 am, VisionIzoizo <[EMAIL PROTECTED]> wrote: > 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... > > 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 -~----------~----~----~----~------~----~------~--~---
