Class::DBI::mysql->set_sql('lastid', 'SELECT LAST_INSERT_ID()'); ## hacked from the Class::DBI::mysql methods sub Class::DBI::mysql::id { my $class = ref $_[0] || $_[0]; my $sth; eval { $sth = $class->sql_lastid(); $sth->execute(); }; if($@) { $class->DBIwarn("lastid"); return; } my $id = $sth->fetch->[0]; $sth->finish(); return $id; }