possible mysql_insert_id() conflicts ?
| From: | rene kretzschmar | Date: | Mon, 17 Sep 2001 18:34:33 +0000 |
| Subject: | possible mysql_insert_id() conflicts ? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-12510@lists.php.net to get a copy of this message | ||
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é