Changeset 377 for trunk/DNSDB.pm
- Timestamp:
- 08/09/12 16:36:01 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r375 r377 2959 2959 $dbh->do("INSERT INTO locations (location, group_id, iplist, description, comments) VALUES (?,?,?,?,?)", 2960 2960 undef, ($loc, $grp, $iplist, $shdesc, $comments) ); 2961 _log($dbh, entry => "Added location ($shdesc, '$iplist')"); 2962 $dbh->commit; 2961 2963 }; 2962 2964 if ($@) { … … 2972 2974 2973 2975 return ('OK',$loc); 2974 } 2976 } # end addLoc() 2975 2977 2976 2978 2977 2979 ## DNSDB::updateLoc() 2978 sub updateLoc {} 2980 sub updateLoc { 2981 my $dbh = shift; 2982 my $loc = shift; 2983 my $grp = shift; 2984 my $shdesc = shift; 2985 my $comments = shift; 2986 my $iplist = shift; 2987 2988 $shdesc = '' if !$shdesc; 2989 $comments = '' if !$comments; 2990 $iplist = '' if !$iplist; 2991 2992 # Allow transactions, and raise an exception on errors so we can catch it later. 2993 # Use local to make sure these get "reset" properly on exiting this block 2994 local $dbh->{AutoCommit} = 0; 2995 local $dbh->{RaiseError} = 1; 2996 2997 my $oldloc = getLoc($dbh, $loc); 2998 my $okmsg = "Updated location (".$oldloc->{description}.", '".$oldloc->{iplist}."') to ($shdesc, '$iplist')"; 2999 3000 eval { 3001 $dbh->do("UPDATE locations SET group_id=?,iplist=?,description=?,comments=? WHERE location=?", 3002 undef, ($grp, $iplist, $shdesc, $comments, $loc) ); 3003 _log($dbh, entry => $okmsg); 3004 $dbh->commit; 3005 }; 3006 if ($@) { 3007 my $msg = $@; 3008 eval { $dbh->rollback; }; 3009 if ($config{log_failures}) { 3010 $shdesc = $loc if !$shdesc; 3011 _log($dbh, (entry => "Failed updating location ($shdesc, '$iplist'): $msg")); 3012 $dbh->commit; 3013 } 3014 return ('FAIL',$msg); 3015 } 3016 3017 return ('OK',$okmsg); 3018 } # end updateLoc() 3019 2979 3020 2980 3021 ## DNSDB::delLoc()
Note:
See TracChangeset
for help on using the changeset viewer.