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 AUTO_INCREMENT. On Mar 22, 7:50 am, WhyNotSmile <[email protected]> wrote: > 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->saveField('landscape', $this->data['PdfPref'] > ['landscape']); > > I've tried various other ways and nothing has worked. I have similar > things working in other models, but this one just won't work for me at > all! > > Can anyone suggest what I'm doing wrong? > > Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
