On Jan 5, 2008 6:51 PM, Travis <[EMAIL PROTECTED]> wrote:
> When I use $this->Customer->Save() this is the message I recieve ...
>
> Query: INSERT INTO `customers`
> (`name`,`street`,`city`,`state`,`zip`,`phone`,`id`,`modified`,`created`)
> VALUES
> ('thomas','','Lafayette','LA','70517','337-555-5555','0','2008-01-05
> 17:48:02','2008-01-05')
>
> Warning (512): SQL Error: 1062: Duplicate entry '0' for key 1 [CORE/
> cake/libs/model/datasources/dbo_source.php, line 440]
>

Well, what jumped out at me right away was the fact that your 'id'
field is set to 0 in the statement above.  So, because 'id' is 0, it
keeps trying to insert a record with an 'id' of 0, which I am assuming
is the primary key for that field.  I'd also bet there is one record
in there with an 'id' of 0, hence SQL complaints about duplicate
entries.

Now, bear with me here and please remember I am trying to help...

You mention above that you have a field called 'id_number' that is
supposed to be the primary key for the table.  Well, in the above
query I don't see any field called 'id_number'.  So, that leads me to
think that the primary key for the table must be 'id'.

In order for the update to work, you need to make sure that
$this->data['Customer']['id'] is set to some value because if it is
missing, then it looks like (to me anyway) that it is defaulting to 0.

Tell me if that makes sense.

-- 
Chris Hartjes
Internet Loudmouth
Motto for 2008: "Moving from herding elephants to handling snakes..."
@TheKeyBoard: http://www.littlehart.net/atthekeyboard

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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