int lastInsertID( resource &$db, string $fieldname )
This function returns the last insert id from the specified database.