--- db/prgsrc/updatedb.pl 2000/10/19 03:05:39 1.7 +++ db/prgsrc/updatedb.pl 2000/10/20 00:39:27 1.9 @@ -22,7 +22,7 @@ The database, user and password are hard Dmitry Rubinstein -=head1 $Id: updatedb.pl,v 1.7 2000/10/19 03:05:39 boris Exp $ +=head1 $Id: updatedb.pl,v 1.9 2000/10/20 00:39:27 boris Exp $ =cut @@ -70,7 +70,7 @@ sub getField { chomp $key; if ($key eq 'Дата') { $value =~ s/^(.*)-(.*)-(.*)$/$3-$2-$1/; - my($month) = $RevMonths{$2}; + my($month) = $RevMonths{$2} || '000'; $value =~ s/$2/$month/; } $value = $dbh->quote($value); @@ -106,6 +106,7 @@ sub SelectGroup { print "[$arr[0]] $arr[1]\n"; } $ParentId = ; + chomp $ParentId; if (!$ParentId) { print "Пропускаем файл $source\n"; print STDERR "Файл $source отвергнут оператором\n"; @@ -115,7 +116,7 @@ sub SelectGroup { $sth = $dbh->prepare("INSERT INTO Tournaments (Title, Type, ParentId, FileName) VALUES ($TourName, 'Ч', $ParentId, - $source"); + $source)"); $sth->execute; my $TournamentId = $sth->{mysql_insertid}; return ($TournamentId,$ParentId); @@ -173,8 +174,27 @@ sub DeleteTournament { if($DeleteMyself) { $sth = $dbh->prepare("DELETE FROM Tournaments WHERE Id=$Id"); + $sth->execute or die $dbh->errstr; } } + +sub GetTours { + my ($dbh, $ParentId) = @_; + my (@arr, @Tours); + + my ($sth) = $dbh->prepare("SELECT Id FROM Tournaments + WHERE ParentId=$ParentId ORDER BY Id"); + + $sth->execute; + + while (@arr = $sth->fetchrow) { + push @Tours, $arr[0]; + } + + return @Tours; +} + + MAIN: { my($key, $value, $addition);