From: http://www.php.net/manual/en/function.mysql-insert-id.php
xochotorena AT arista IN Spain
06-Aug-2001 03:02
From mysql's manual:
"The last ID that was generated is maintained in the server on a
per-connection
basis. It will not be changed by another client. It will not even be
changed if
you update another AUTO_INCREMENT column with a non-magic value (that is,
a value that is not NULL and not 0)."
As each thread is using it's own connection there is no need to lock the
table.
... that should answer your question. No need to worry, just trust that
MySQL will handle it for you.
Justin Buist
Trident Technology, Inc.
4700 60th St. SW, Suite 102
Grand Rapids, MI 49512
Ph. 616.554.2700
Fx. 616.554.3331
Mo. 616.291.2612
On Mon, 17 Sep 2001, rene kretzschmar wrote:
> hi,
>
> Imagine the following php+mysql scenario:
>
> there are two tables:
> create table testuser(id int not null auto_increment, name varchar(255),
> primary key(id));
> create table testaddress(id int not null auto_increment, user int not
> null,street varchar(255), primary key(id));
>
> the *.php test script contains the following lines:
> mysql_query("insert into testuser (name) ('testname')");
> //<--* (see below)
> $userid = mysql_insert_id();
> mysql_query("insert into testaddress(user,street)
> values('$userid','teststreet')");
>
> * at this time another thread could insert another record into testuser
>
> and the logical question: Will I get the right $userid from
> mysql_insert_id() anyway ??
>
> thanx - rené
>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]