check if user allready exists in koha
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 15 Aug 2011 17:05:44 +0000 (19:05 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 15 Aug 2011 17:05:44 +0000 (19:05 +0200)
isvu-import.pl

index b5ad116..9aa8833 100755 (executable)
@@ -11,12 +11,17 @@ use FERWeb;
 
 my $f = FERWeb->new;
 my $c = DBI->connect("dbi:CSV:","","", { RaiseError => 1, f_ext => '.csv', f_encoding => 'utf-8' }) || die $dbi::errstr;
+my $k = DBI->connect("dbi:mysql:database=koha_fer","","", { RaiseError => 1, AutoCommit => 0, mysql_enable_utf8 => 1 }) || die $DBI::errstr;
 
 my $s = $c->prepare(qq{
 select * from brucosi_2011_ISVU
 });
 $s->execute;
 
+my $user_exists = $k->prepare(qq{
+select * from borrowers where cardnumber = ?
+});
+
 while( my $row = $s->fetchrow_hashref ) {
 
        warn "# row = ",dump($row),$/;
@@ -25,9 +30,17 @@ while( my $row = $s->fetchrow_hashref ) {
 
        warn "# user = ", dump($user), $/;
 
+       $user_exists->execute( 'S' . $row->{jmbag} );
+
+       if ( $user_exists->rows ) {
+               warn "EXISTS: ",dump($row);
+               print "#";
+       }
+
        print join(" "
                , $row->{jmbag}
                , $user->{nick}
                , $user->{email}
        ),$/;
+
 }