Diff for /db/prgsrc/updatem.pl between versions 1.1 and 1.2

version 1.1, 2000/10/17 01:34:16 version 1.2, 2000/10/17 01:47:34
Line 26  Dmitry Rubinstein Line 26  Dmitry Rubinstein
   
 =cut  =cut
   
       use strict;
   use vars qw($opt_m);
   
   use Getopt::Std;
 use DBI;  use DBI;
   
 MAIN:   MAIN: 
 {  {
           getopts('m:') or die "Wrong options";
         my($source) = 'meta';          my($source) = $opt_m || 'meta';
         my($depth, @depthId);          my($depth, @depthId);
         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";
   
         open INFD, $source or die "Can't open input file: $!\n";          open INFD, $source or die "Can't open input file: $!\n";
         while (<INFD>) {          while (<INFD>) {
               my $MetaId;
                 s/^\[(\d*)\]\t//;                  s/^\[(\d*)\]\t//;
                 $MetaId = $1;                  $MetaId = $1;
                 s/^(\t*)//;                  s/^(\t*)//;
                 chomp;                  chomp;
                 $depth = length($1);                  $depth = length($1);
                 $title = $dbh->quote($_);                  my $title = $dbh->quote($_);
                 $ParentId = ($depth) ? $depthId[$depth - 1] : 0;                  my $ParentId = ($depth) ? $depthId[$depth - 1] : 0;
                 my ($sth) = $dbh->prepare("SELECT Id FROM Tournaments WHERE                  my ($sth) = $dbh->prepare("SELECT Id FROM Tournaments WHERE
                         MetaId=$MetaId");                          MetaId=$MetaId");
                 $sth->execute;                  $sth->execute;
Line 56  MAIN: Line 61  MAIN:
                         (Title, ParentId, MetaId, Type)                           (Title, ParentId, MetaId, Type) 
                         VALUES ($title, $ParentId, $MetaId, 'ç')");                          VALUES ($title, $ParentId, $MetaId, 'ç')");
                 $sth->execute;                  $sth->execute;
                 $Id = $sth->{insertid};                  my $Id = $sth->{'insertid'};
                 $depthId[$depth] = $Id;                  $depthId[$depth] = $Id;
         }          }
         $dbh->disconnect;          $dbh->disconnect;

Removed from v.1.1  
changed lines
  Added in v.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>