Why have a primary key which does not auto increment? Your query shows why this is a very bad idea as your trying to insert a record and have not included a primary key value so the database has tried to create one for you that already exists (probably '0').
And why prefix your prinary key with the table name? This means you require more configuration (plus support on how to achieve that configuration) and will constantly be typing extra data when using this field, i.e. $this->data['Deal']['deal_id'] instead of $this- >data['Deal']['id']. The fact that the id field is in the deals table gives it a context so there is no need to prefix it. You will make life much much easier for yourself if you start using conventions (and not just CakePHP conventions this is pretty much a standard convention for any database table) rather than fighting against them with your own methods. HTH, Paul. On Aug 25, 12:28 pm, Sebastian Henschel <s.hensc...@stattwerk.com> wrote: > heya... > > Am Thursday, den 25.08.2011, 16:24 +0530 schrieb abhimanyu bv: > > > the primary key field is deal_id. it is not an auto-increment > > field.while saving, i am giving a value to deal_id and there are no > > ids with the same in that table.it doesnt have any dependencies. > > please provide us with the code that defines the deal_id, because: > > (please keep relevant text from previous mails in your replies) > > > i developed a page to save deals into database.till yesterday it was > > working fine.now its not working, an error is coming like SQL Error: > > 1062: Duplicate entry '' for key 'PRIMARY'. and query it showng is > > Query: INSERT INTO `deals` (`no_of_coupons`, `deal_type_id`, > > `disabled`, `modified`, `created`) VALUES (0, 0, 0, '2011-08-25 > > 14:34:13', '2011-08-25 14:34:13') . while in the data array i am > > passing integers to no_of_coupons, deal_type_id. how to fix this > > error? > > the INSERT statement doesn't seem to use a field named 'deal_id'. > > bye, > Sebastian -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php