Name

last_insert_id( )

Synopsis

$database_handle->last_insert_id( )

This returns the value stored in the row identification column of the most recent row inserted for the current MySQL session, provided the identification number was incremented using AUTO_INCREMENT in MySQL. It works like the LAST_INSERT_ID( ) function in MySQL. No arguments for this function are necessary with MySQL. This function doesn’t work with MySQL before Version 1.45 of DBI.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.