--- "Chris W. Parker" <[EMAIL PROTECTED]> wrote: > > If the id is auto increment, can't you use max(id) to get the last > > inserted one? > > only if you are the absolute only person that will ever be connected to > that db at one time. otherwise the answer is no. > > what if in between your INSERT INTO statement and your SELECT statement > someone else writes a record? for a high traffic website it's very > possible that someone will insert another record before you can turn > around and read the table.
This is a very good explanation. Also, before you start thinking that these types of synchronization problems don't apply to you, because you're on a dedicated box, consider that Apache (or whatever Web server you are using) can potentially have many child processes serving all of your users. Thus, there may be many connections to the database, and all of them may be inserting into this table. The function to retrieve the last ID is for a single connection, therefore these types of synchronization issues aren't a problem. Hope that helps. Chris ===== Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming mid-2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php