version 1.2, 2001/07/28 17:23:02
|
version 1.4, 2001/07/28 21:21:29
|
Line 38 use DBI;
|
Line 38 use DBI;
|
|
|
MAIN: |
MAIN: |
{ |
{ |
my $USAGE="Usage: deletefiles.pl [-y|-n] file file file...\n"; |
my $USAGE="Usage: deletefiles.pl file file file...\n"; |
my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "") |
my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "") |
or die "Can't connect to DB chgk\n"; |
or die "Can't connect to DB chgk\n"; |
foreach my $file (@ARGV) { |
foreach my $file (@ARGV) { |
Line 46 MAIN:
|
Line 46 MAIN:
|
select Id,ParentId,QuestionsNum from Tournaments |
select Id,ParentId,QuestionsNum from Tournaments |
where Type='þ' and FileName='$file'"); |
where Type='þ' and FileName='$file'"); |
$sth->execute; |
$sth->execute; |
|
if (!$sth->rows) { |
|
print STDERR "File $file is not found in the database\n"; |
|
next; |
|
} |
while (my ($Id,$ParentId,$QuestionsNum) = $sth->fetchrow) { |
while (my ($Id,$ParentId,$QuestionsNum) = $sth->fetchrow) { |
print "Deleting $file Id=$Id, $QuestionsNum questions\n"; |
print STDERR "Deleting $file, Id=$Id, $QuestionsNum questions\n"; |
UpdateParents($dbh,$ParentId,$QuestionsNum); |
UpdateParents($dbh,$ParentId,$QuestionsNum); |
UpdateChildrenAndDie($dbh,$Id); |
UpdateChildrenAndDie($dbh,$Id); |
} |
} |