List:General Discussion« Previous MessageNext Message »
From:Philippe Poelvoorde Date:February 15 2005 10:50am
Subject:Re: last_insert_id
View as plain text  
mel list_php wrote:
> Hi!
> 
> I have a database where several users can connect and input data.
> 
> I managed to have my insert queries as atomic, but I was wondering about 
> one special case: I make one insert, and retrieve the last id inserted 
> by mysql because I need to update an other table with that id.
> 
> - if one user inserts and retrieves the id, but between both one other 
> has inserted something the id returned will be the right one?

Last_insert_id() is consistent on a per-connection basis, meaning you 
don't need to use lock (hopefullly !)
http://dev.mysql.com/doc/mysql/en/getting-unique-id.html

btw, what do you mean by : "I managed to have my insert queries as 
atomic". Because if you do : INSERT .... it's already suppose to be atomic.

HIMH.

-- 
Philippe Poelvoorde
COS Trading Ltd.
Thread
last_insert_idmel list_php15 Feb
  • Re: last_insert_idJohan Höök15 Feb
  • Re: last_insert_idAlec.Cawley15 Feb
  • Re: last_insert_idPhilippe Poelvoorde15 Feb
    • Re: last_insert_idmel list_php15 Feb
    • Re: last_insert_idmel list_php15 Feb
    • Re: last_insert_idmel list_php15 Feb