When i try to a edit a entry.. its creating a duplicate entry in the database.
i have made sure i add an hidden id field when i go to the edit form.
Restaurant
RestaurantAttribute
RestaurantContact
these are the models i am using.
tried reinitialize the id
$this->Restaurant->id = $this->Restaurant->id;
strange… in the db the extra entry is not there…
but in cake its displaying..tried to clear the cache.. still happening
http://harshamv.com/files/screenshots/2010-07-07_1524.png
http://harshamv.com/files/screenshots/2010-07-07_1525.png
i have posted the code here
http://forum.phpvideotutorials.com/showthread.php?p=81936
here is the index action http://bin.cakephp.org/view/660872993
here is the model http://bin.cakephp.org/view/1228539627
http://harshamv.com/files/screenshots/2010-07-10_0937.png
SQL Statement http://pastebin.com/EmdXmNeH
Restaurant Model http://pastebin.com/W1sLiL7W
I got the answer from teknoid from the MIRC.
In my edit view i have only set the Restaurant.id.
none of the ids of the related models are set in the view.
By cake’s convention we need to have the id of any record from the db u update. so this was creating a duplicate record in the related models.
In the index action since there is a JOIN of related models. it was creating duplicate entries because of repeated entries in the related model
by adding the ids of all the related model records. this solved the problem.
Thanks all for your time. Finally i managed to get it working.