Skip to content

Commit

Permalink
$self->{id} was not updated when the id in the database was automatic…
Browse files Browse the repository at this point in the history
…ally incremented when a new subnet was inserted.
  • Loading branch information
Niklas Brandt committed Apr 26, 2010
1 parent 3b948f8 commit 435fe41
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions HOSTDB/Object/Subnet.pm
Expand Up @@ -98,6 +98,9 @@ sub init
or die "$DBI::errstr";
$self->{_delete_subnet} = $hostdb->{_dbh}->prepare ("DELETE FROM $hostdb->{db}.subnet WHERE id = ?")
or die "$DBI::errstr";

$self->{_get_last_id} = $hostdb->{_dbh}->prepare ("SELECT LAST_INSERT_ID()")
or die "$DBI::errstr";
} else {
$hostdb->_debug_print ("NOT preparing database stuff (since my HOSTDB has no DBH)");
}
Expand Down Expand Up @@ -171,6 +174,13 @@ sub commit
$sth->execute (@db_values) or die "$DBI::errstr";

$sth->finish ();

# fill in $self->{id}
$sth = $self->{_get_last_id};
$sth->execute () or die "$DBI::errstr";
my @t = $sth->fetchrow_array ();
$self->{id} = $t[0];
$sth->finish ();
}

return 1;
Expand Down

0 comments on commit 435fe41

Please sign in to comment.