on ma, 10 feb 2003 19:04:01 GMT, Mario Kulka wrote: > $sth = $dbh->prepare ("SELECT LAST_INSERT_ID() FROM $table"); > $sth -> execute(); > $ad_id = $sth->fetchrow_array(); > $sth->finish(); > ... > > The above works fine and gives me the last id, but what worries me is > the possibility of someone submitting new record between the lines > "Insert record" and the rest. Is that a valid concern?
You don't have to worry about this, because the result of the LAST_INSERT_ID() function is maintained by the server on a per-connection basis. You do have to worry about your 'SELECT LAST_INSERT_ID() FROM atable' syntax though, which does not return what you expect. In fact, it returns as many rows as there are in atable, each containing the value of the auto_increment field generated in the last INSERT statement, regardless which table the INSERT statement whas issued for. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]