Retrieves the ID from the previous INSERT query on this database connection.
mysql_insert_id()
is used to retrieve the ID from a previous INSERT query on this database connection.
The query must have been made to a table that has an auto_increment
field - that is the field that will be returned.
You can pass in an optional parameter, which is the database connection to use; otherwise it will use the most recently opened database connection as a default.
Note that this function is connection-based - two separate processes invoking this function separately will create two separate connections to the database, which means that each process will return the correct ID for its own insert.
Note that as of PHP 5.5.0, this function has been deprecated.