A word of warning to the unwary:
This post started me thinking:
http://www.phpbuilder.com/forum/read.php3?num=5&id=20715&loc=0&thread=20715
And I thought:
MySQL stores the auto_increment values on a per-connection basis.
mysql_pconnect() keeps connections open for re-use.
Thus the auto_increment value would remain available on those connections, for as long as they live.
And a little test proves that this does indeed happen.
If script A opens a pconnect to the server and inserts a record, then afterwards script B can also open a pconnect, and read the auto_increment value that A generated.
I haven't tested this on other databases, but if PHP's approach is the same, I expect the results to be the same.
But this is not a big problem because we all use proper error checking right? We all make sure that the insert query actually worked before we read the mysql_insert_id() don't we? 🙂