Changeset 22 for trunk/DNSDB.pm
- Timestamp:
- 10/15/09 17:50:22 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r20 r22 23 23 @ISA = qw(Exporter); 24 24 @EXPORT_OK = qw( 25 &initGlobals &connectDB &finish &addDomain &delDomain &domainName &addGroup &getChildren &groupName 26 &getSOA &getRecLine &getDomRecs &addRec &updateRec &delRec &domStatus 25 &initGlobals &connectDB &finish 26 &addDomain &delDomain &domainName 27 &addGroup &delGroup &getChildren &groupName 28 &getSOA &getRecLine &getDomRecs 29 &addRec &updateRec &delRec 30 &domStatus 27 31 %typemap %reverse_typemap 28 32 ); … … 30 34 @EXPORT = (); # Export nothing by default. 31 35 %EXPORT_TAGS = ( ALL => [qw( 32 &initGlobals &connectDB &finish &addDomain &delDomain &domainName &addGroup &getChildren 33 &groupName &getSOA &getRecLine &getDomRecs &addRec &updateRec &delRec &domStatus 36 &initGlobals &connectDB &finish 37 &addDomain &delDomain &domainName 38 &addGroup &delGroup &getChildren &groupName 39 &getSOA &getRecLine &getDomRecs 40 &addRec &updateRec &delRec 41 &domStatus 34 42 %typemap %reverse_typemap 35 43 )] … … 225 233 $sth->execute($domid); 226 234 235 #die "full of fail\n"; 227 236 # once we get here, we should have suceeded. 228 $dbh->commit;237 # $dbh->commit; 229 238 }; # end eval 230 239 … … 302 311 } 303 312 304 die "epic FAIL.. hahahah, just testing!\n";305 313 # once we get here, we should have suceeded. 306 314 $dbh->commit; … … 316 324 317 325 } # end addGroup() 326 327 328 ## DNSDB::delGroup() 329 # Delete a group. 330 # Takes a group ID 331 # Returns a status code and message 332 sub delGroup { 333 my $dbh = shift; 334 my $groupid = shift; 335 336 # Allow transactions, and raise an exception on errors so we can catch it later. 337 # Use local to make sure these get "reset" properly on exiting this block 338 local $dbh->{AutoCommit} = 0; 339 local $dbh->{RaiseError} = 1; 340 341 ##fixme: locate "knowable" error conditions and deal with them before the eval 342 # -> domains still exist in group 343 # -> ... 344 345 # Wrap all the SQL in a transaction 346 eval { 347 my $sth = $dbh->prepare("delete from default_records where group_id=?"); 348 $sth->execute($groupid); 349 $sth = $dbh->prepare("delete from groups where group_id=?"); 350 $sth->execute($groupid); 351 352 die "epic group fail FTW!\n"; 353 # once we get here, we should have suceeded. 354 $dbh->commit; 355 }; # end eval 356 357 if ($@) { 358 my $msg = $@; 359 eval { $dbh->rollback; }; 360 return ('FAIL',$msg); 361 } else { 362 return ('OK','OK'); 363 } 364 } # end delGroup() 318 365 319 366
Note:
See TracChangeset
for help on using the changeset viewer.