--- db/prgsrc/updatedb.pl 2000/10/17 02:24:47 1.3 +++ db/prgsrc/updatedb.pl 2000/10/17 16:56:09 1.4 @@ -22,14 +22,17 @@ The database, user and password are hard Dmitry Rubinstein -=head1 $Id: updatedb.pl,v 1.3 2000/10/17 02:24:47 boris Exp $ +=head1 $Id: updatedb.pl,v 1.4 2000/10/17 16:56:09 boris Exp $ =cut my (%RevMonths) = - ('Jan', '1', 'Feb', '2', 'Mar', '3', 'Apr', '4', 'May', '5', 'Jun', '6', + ('Jan', '1', 'Feb', '2', 'Mar', '3', 'Apr', '4', 'May', '5', 'Jun', '6', 'Jul', '7', 'Aug', '8', 'Sep', '9', 'Oct', '10', 'Nov', '11', 'Dec', '12', + 'JAN', '1', 'FEB', '2', 'MAR', '3', 'APR', '4', 'MAY', '5', 'JUN', '6', + 'JUL', '7', 'AUG', '8', 'SEP', '9', 'OCT', '10', 'NOV', '11', + 'DEC', '12', 'Янв', '0', 'Фев', 1, 'Мар', 2, 'Апр', 3, 'Май', '4', 'Июн', '5', 'Июл', 6, 'Авг', '7', 'Сен', '8', 'Окт', '9', 'Ноя', '19', 'Дек', '11'); @@ -37,7 +40,7 @@ my ($sth); use vars qw($/); -$/=/\n */; + use DBI; use strict; @@ -99,8 +102,7 @@ sub SelectGroup { Tournaments WHERE Type = 'Г'"); $sth->execute; print "Выберите группу для турнира:\n$TourName\n\n"; - for ($i = 0; $i < $sth->numrows; $i++) { - @arr = $sth->fetchrow; + while (@arr=$sth->fetchrow) { print "[$arr[0]] $arr[1]\n"; } $ParentId = ; @@ -136,6 +138,7 @@ MAIN: my($tournum, $qnum, $all_qnum, $qtype) = (0, 0, 0, 'Ч'); my (@d) = (localtime((stat($source))[9]))[5,4,3]; $d[1]++; + $d[0]+=1900; my ($CreatedAt) = $dbh->quote( join('-', @d)); print "File created on: $CreatedAt\n"; @@ -175,7 +178,7 @@ MAIN: WHERE Id=$TourId"); } $qnum = 0; - $qtype = "Ч"; + $qtype = 'Ч'; $sth = $dbh->prepare("INSERT INTO Tournaments (Title, Type, ParentId, CreatedAt) VALUES ($value, 'Т', $TournamentId, $CreatedAt)"); @@ -185,13 +188,15 @@ MAIN: } if ($key =~ /Вид/) { $qtype = $value; + $qtype =~ s/'//g; next; } if ($key =~ /Вопрос/) { - $sth = $dbh->prepare("INSERT INTO Questions + my $query = "INSERT INTO Questions (ParentId, Number, Type) - VALUES ($TourId, $qnum+1, $qtype)"); - $sth->execute or print "Problem at $qnum"; + VALUES ($TourId, $qnum+1, \'$qtype\')"; + $sth = $dbh->prepare($query); + $sth->execute or print $query;; $QuestionId = $sth->{mysql_insertid}; &UpdateQuestion($dbh, $QuestionId, "Question", $value); $qnum++;