Re: MySQL error on field update

2010-03-23 Thread WhyNotSmile
Thanks everyone! It turned out that the db field wasn't set to auto-increment. I thought it was, but must have forgotten to tick the box and not noticed! Once I changed that, it worked fine. Thanks again for the help. Check out the new CakePHP Questions site http://cakeqs.org and help others w

Re: MySQL error on field update

2010-03-23 Thread WebbedIT
There can't be a primary key ID of 0 as 0 = false. As such you're not passing an id to saveField so it's running an INSERT instead of an UPDATE. You need to take a look at your db table definition as it should not allow a primary key of 0 if it's an INT/Primary Key/Auto Increment which it should

RE: MySQL error on field update

2010-03-22 Thread Alan Asher
Monday, March 22, 2010 4:51 AM To: CakePHP Subject: MySQL error on field update I'm trying to update a record in the database, but I keep getting an error saying SQL Error: 1062: Duplicate entry '0' for key 'PRIMARY' Query: INSERT INTO `pdf_prefs` (`landscape`) VALUES (

Re: MySQL error on field update

2010-03-22 Thread cricket
Like the msg says, it looks like you already have a row in the DB with ID = 0. As it's the Primary Key, it must be unique. But you should never have any records that have the PKs set to 0, anyway. How did you specify this column when you created the table? It should be some flavour of INT and be A

MySQL error on field update

2010-03-22 Thread WhyNotSmile
I'm trying to update a record in the database, but I keep getting an error saying SQL Error: 1062: Duplicate entry '0' for key 'PRIMARY' Query: INSERT INTO `pdf_prefs` (`landscape`) VALUES ('L') Here's what I'm doing: $this->PdfPref->id = $id;/* $id = 0 in this case */ $this->PdfPref->saveFi