Hi Soulcatcher This issue has been covered a number of times in this group, but can be hard to find. Short answer is that it is quite safe.
Retrieving the last inserted ID is done in the context of your current MySQL connection. So it doesn't matter if other people are saving at the same time. My understanding is that this is handled by PHP and MySQL. If you search the group for "getLastInsterId" you should find the details (expressed much better than I have here). Regards, Langdon Soulcatcher wrote: > Hi, i'm new to Cake and i have a question about synchro issue. When > you have related tables (say table B has a foreign key pointing to > table A) and you want to save 2 related tuples, it's written in Manual > that you have to > > 1) Save tuple in table A > 2) Get last id from A > 3) Save tuple in table B using that last id wich we got in step2 as a > foreign key. > > Now, my question is - what happens if in the time between i save tuple > to A and get last id from A there were, like, 1000 new tuples inserted > to A? For example, i save my furst tuple in A, it has id=1. Then i try > to get this id from A, but by the time i execute this request, someone > already inserted 2 tuples into A, so i get last id equal to 3, wich > isnt what i want (i want id=1). > > Is this a problem? Maybe you have some links describing this already, > i couldnt find it. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
