Re: Creating alphanumeric id for a table

From: Date: Tue, 15 Sep 2009 05:43:26 +0000
Subject: Re: Creating alphanumeric id for a table
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-298058@lists.php.net to get a copy of this message
> 1. user A insert into table (get id = 1 from auto increment value) > 2. user B insert into table (get id = 2 from auto increment value) > 3. user A get value from $id = LAST_INSERT_ID() (id = 2) > 4. user B get value from $id = LAST_INSERT_ID() (id =2) [8<] > How can we make sure that those 3 processes are atomic operation (insert > table -> get id from LAST_INSERT_ID() -> update table) ?? From the MySQL 5.0 manual (20.9.10.3): For LAST_INSERT_ID(), the most recently generated ID is maintained in the server on a per-connection basis. It is not changed by another client. ... Using LAST_INSERT_ID() and AUTO_INCREMENT columns simultaneously from multiple clients is perfectly valid. Each client will receive the last inserted ID for the last statement /that/ client executed. http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html Ben

« previous php.general (#298058) next »