Re: PHP and MySQL Insert ID

From: Date: Wed, 01 Aug 2001 09:18:53 +0000
Subject: Re: PHP and MySQL Insert ID
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-60606@lists.php.net to get a copy of this message
Hello John, Wednesday, August 01, 2001, 11:06:06 AM, you wrote: JM> In an environment where it's possible to have multiple JM> users register at the same time (relatively speaking), how can I be sure JM> that the 'last ID' is indeed the 'intended' last user's ID? JM> Ex. JM> Say that user A submit a registration form at 00:00:01, but JM> mysql_inserted_id is not called (for user A) until 00:00:03. JM> If user B submits a registration for at 00:00:02, then would JM> the call to mysql_insert_id (for user A---called at 00:00:03) return JM> the ID for user B? JM> Technically, it sounds like it would, unless mysql_insert_id implements JM> some type of session and/or state recognition. JM> Is that how it works? JM> --How can I be sure that it returns the ID for user A and not B? You can be 100% sure, 'cause mysql_insert_id() returning last inserted id in current connection to database. User A has another connection ID as user B. I hope it helps -- Best regards, Daniel mailto:daniel@rezny.sk

« previous php.general (#60606) next »