last_insert_id function for database.