HI,

I'm trying to update a record through the controller action customers/
edit/id_number.  This loads a form prepopulated with the customer data
associated with id_number.  The form posts to customers/edit.

The id_number field is an auto increment integer that is the primary
key on the table.  When I try to call Save() or Update() in my
controller, I get sql errors.  Here's the latest attempt at my
controller logic.  Any advice would be appreciated !

function edit($id = null){
                if (empty($this->data))
                {
                        $this->Customer->id = $id;
                        $this->data = $this->Customer->read();
                }
                else
                {
                        $this->Customer->save($this->data['Customer']);

                        $this->flash('Your customer data has been updated.', 
'/customers');

                }
        }

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]


When I use $this->Customer->Update() this is the message I recieve

Query: update

Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near '' at line 1 [CORE/cake/libs/model/
datasources/dbo_source.php, line 440]


--~--~---------~--~----~------------~-------~--~----~
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