/[webpac2]/trunk/lib/WebPAC/Input/Koha.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Input/Koha.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1325 by dpavlin, Tue Feb 2 18:03:17 2010 UTC revision 1326 by dpavlin, Tue Feb 2 19:30:48 2010 UTC
# Line 47  sub new { Line 47  sub new {
47                  $arg->{dsn}    ||= 'dbi:mysql:database=koha';                  $arg->{dsn}    ||= 'dbi:mysql:database=koha';
48                  $arg->{user}   ||= $ENV{KOHA_USER};                  $arg->{user}   ||= $ENV{KOHA_USER};
49                  $arg->{passwd} ||= $ENV{KOHA_PASSWD},                  $arg->{passwd} ||= $ENV{KOHA_PASSWD},
50                  $arg->{sql}    ||= 'select biblionumber as mfn, marc from biblioitems';                  $arg->{sql}    ||= 'select biblionumber, marc from biblioitems order by biblionumber asc';
51                  $arg->{sql}    .= ' limit ' . $arg->{limit} if $arg->{limit};                  $arg->{sql}    .= ' limit ' . $arg->{limit} if $arg->{limit};
52                  $arg->{sql}    .= ' offset ' . $arg->{offset} if $arg->{offset};                  $arg->{sql}    .= ' offset ' . $arg->{offset} if $arg->{offset};
53    
54                  $log->info("opening Koha database '$arg->{dsn}'");                  $log->info("opening Koha database '$arg->{dsn}'");
55    
56                  $self->{_dbh} = DBI->connect( $arg->{dsn}, $arg->{user}, $arg->{passwd}, { RaiseError => 1 } );                  $self->{_dbh} = DBI->connect( $arg->{dsn}, $arg->{user}, $arg->{passwd}, {
57                            RaiseError => 1,
58                            #mysql_enable_utf8 => 1, # not really needed
59                    } );
60                  $self->{_sth} = $self->{_dbh}->prepare( $arg->{sql} );                  $self->{_sth} = $self->{_dbh}->prepare( $arg->{sql} );
61                  $self->{_sth}->execute;                  $self->{_sth}->execute;
62                  $self->{_koha_size} = $self->{_sth}->rows;                  $self->{_koha_size} = $self->{_sth}->rows;
# Line 82  sub fetch_rec { Line 85  sub fetch_rec {
85    
86          my $row = $self->{_sth}->fetchrow_hashref;          my $row = $self->{_sth}->fetchrow_hashref;
87    
88            sub _error {
89                    my ( $mfn, $error, $row ) = @_;
90                    $self->_get_logger()->error( "MFN $mfn $error ", dump($row) );
91            }
92    
93          if ( my $fh = $self->{_koha_fh} ) {          if ( my $fh = $self->{_koha_fh} ) {
94                  if ( my $marc = $row->{marc} ) {                  if ( my $marc = $row->{marc} ) {
95                          print $fh $marc;                          if ( length($marc) != substr( $marc, 0, 5 ) ) {
96                                    _error $mfn => "wrong length " . length($marc), $row;
97                            } elsif ( $marc !~ /\x1E\x1D$/ ) {
98                                    _error $mfn => "wrong end", $row;
99                            } else {
100                                    print $fh $marc;
101                            }
102                  } else {                  } else {
103                          warn "MFN $mfn no marc in ",dump($row);                          _error $mfn => "no marc",$row;
104                  }                  }
105          }          }
106    

Legend:
Removed from v.1325  
changed lines
  Added in v.1326

  ViewVC Help
Powered by ViewVC 1.1.26