I usually use $this->ModelName->create();

On Feb 6, 2008 5:50 PM, Tim W <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I've got a piece of code that does an insert, then and update of the
> previous row inserted, then the code loops around and does the same
> thing again for a different data set. I've found an issue that the
> second time around the loop the AppModel is retaining the ID of the
> previous insert and so is doing an update instead of an insert. After
> stepping into the model.php source eventually found that it was
> getting an ID from "$this->contr->ModelName->id" that was saved on the
> previous insert.
>
> Adding "$this->contr->ModelName->id = null" fixed the issue, and made
> the model do an insert instead of an update. This feels like a hack
> though, and I don't like hacks, they often come back to bite you
> later.
>
> Does anyone know why the model's retaining this ID value, and why it's
> picking it up from the previous insert when it's missing from the
> array of data I tell it to save?
>
> Thanks
>
> Tim
> >
>



-- 
-- 
(the old fart) the advice is free, the lack of crankiness will cost you

- its a fine line between a real question and an idiot

http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/
http://blog.samdevore.com/cakephp-pages/my-cake-wont-bake/
http://blog.samdevore.com/cakephp-pages/i-cant-bake/

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