[RESOLVED] LAST_INSERT_ID() is it safe with multiple users
Results 1 to 3 of 3

Thread: [RESOLVED] LAST_INSERT_ID() is it safe with multiple users

  1. #1
    Senior Member
    Join Date
    May 2003

    resolved [RESOLVED] LAST_INSERT_ID() is it safe with multiple users

    Lets say I had a big site and I wanted to use

    Would this always give me the correct info, even if I have lots of people updating the database at the same time?

    For instance, I have a table called cars that I am inserting into a car, but I also have to update a table cars_countries, so I have to know the ID of the last car I updated that happens just milliseconds before because I have a form that will insert into both tables.

    Or is there a way to do some kind of cascade update when you have foreign keys that would automatically update cars_countries with the car_id and country_id?

  2. #2
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    You do not state what DBMS you are using, but at least for MySQL you should be OK, as the insert ID is on a per-connection basis. (All bets are off, though, if for some reason you are using persistent connections, such as via mysql_pconnect().)
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because hes a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


  3. #3
    Senior Member
    Join Date
    May 2003
    thanks, i am using mysql

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts