--- db/prgsrc/updatedb.pl 2000/10/20 01:45:46 1.10 +++ db/prgsrc/updatedb.pl 2000/10/22 02:25:02 1.12 @@ -22,7 +22,7 @@ The database, user and password are hard Dmitry Rubinstein -=head1 $Id: updatedb.pl,v 1.10 2000/10/20 01:45:46 boris Exp $ +=head1 $Id: updatedb.pl,v 1.12 2000/10/22 02:25:02 boris Exp $ =cut @@ -64,7 +64,7 @@ sub getField { my($key); my($value) = (''); while (<$desc>) { - s/ //g; + s/[ ]//g; if ($key && /^\s*$/) { chomp $value; chomp $key; @@ -78,8 +78,9 @@ sub getField { } next if (/^\s*$/); - if (/^(.*)[:\.][\s]*$/ && !$key) { + if (s/^(.*?)[:\.]\s*// && !$key) { $key = $1; + $value=$_; next; } if ($key) { @@ -169,7 +170,7 @@ sub DeleteTournament { } my (@Tours) = &GetTours($dbh, $Id); foreach my $Tour (@Tours) { - DeleteTournament($dbh,$Tour,1); + DeleteTournament($dbh,$Tour,$Id,0,1); } my $sth = $dbh->prepare("DELETE FROM Questions WHERE ParentId=$Id"); @@ -249,7 +250,6 @@ MAIN: WHERE Id=$TourId"); } $qnum = 0; - $qtype = 'Ч'; $sth = $dbh->prepare("INSERT INTO Tournaments (Title, Type, ParentId, CreatedAt) VALUES ($value, 'Т', $TournamentId, @@ -264,6 +264,15 @@ MAIN: next; } if ($key =~ /Вопрос/) { + if (!$TourId) { + $qnum = 0; + $sth = $dbh->prepare("INSERT INTO Tournaments + (Title, Type, ParentId, CreatedAt) + VALUES ('1', 'Т', $TournamentId, + $CreatedAt)"); + $sth->execute; + $TourId = $sth->{mysql_insertid}; + } my $query = "INSERT INTO Questions (ParentId, Number, Type) VALUES ($TourId, $qnum+1, \'$qtype\')";