Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ce52db90

Von Sven Schöling vor etwa 8 Jahren hinzugefügt

  • ID ce52db90975ded77bfa2037b5c2957e0f883240f
  • Vorgänger ef058994
  • Nachfolger 95f601bd

USTVA: single-dbh disconnects

Unterschiede anzeigen:

SL/USTVA.pm
27 27

  
28 28
use List::Util qw(first);
29 29

  
30
use SL::DB;
30 31
use SL::DBUtils;
31 32
use SL::DB::Default;
32 33
use SL::DB::Finanzamt;
......
128 129
    $where_dcp
129 130
  |;
130 131

  
131
  my $dbh = $form->dbconnect($myconfig);
132
  my $sth = $dbh->prepare($query);
133

  
134
  $sth->execute() || $form->dberror($query);
135

  
136 132
  my @positions;
137 133

  
138
  while ( my $row_ref = $sth->fetchrow_arrayref() ) {
139
    push @positions, @$row_ref;  # Copy the array contents
140
  }
134
  SL::DB->client->with_transaction(sub {
135
    my $dbh = SL::DB->client->dbh;
136
    my $sth = $dbh->prepare($query);
141 137

  
142
  $sth->finish;
138
    $sth->execute() || $form->dberror($query);
143 139

  
144
  $dbh->disconnect;
140
    while ( my $row_ref = $sth->fetchrow_arrayref() ) {
141
      push @positions, @$row_ref;  # Copy the array contents
142
    }
145 143

  
146
  return @positions;
144
    $sth->finish;
145
    1;
146
  }) or do { die SL::DB->client->error };
147 147

  
148
  return @positions;
148 149
}
149 150

  
150 151

  
......
505 506

  
506 507
  my ($self, $myconfig, $form) = @_;
507 508

  
508
  my $dbh = $form->dbconnect($myconfig) or $self->error(DBI->errstr);
509
  my $dbh = SL::DB->client->dbh;
509 510

  
510 511
  #Test, if table finanzamt exist
511 512
  my $table    = 'finanzamt';
......
516 517
    #There is no table, read the table from sql/finanzamt.sql
517 518
    print qq|<p>Bitte warten, Tabelle $table wird einmalig in Datenbank:
518 519
    $myconfig->{dbname} als Benutzer: $myconfig->{dbuser} hinzugefügt...</p>|;
519
    process_query($form, $dbh, $filename) || $self->error(DBI->errstr);
520

  
521
    #execute second last call
522
    my $dbh = $form->dbconnect($myconfig) or $self->error(DBI->errstr);
523
    $dbh->disconnect();
520
    SL::DB->client->with_transaction(sub {
521
      process_query($form, $dbh, $filename) || $self->error(DBI->errstr);
522
      1;
523
    }) or do { die SL::DB->client->error };
524 524
  };
525 525
  $tst->finish();
526 526

  
......
601 601

  
602 602
  my ($self, $myconfig, $form) = @_;
603 603

  
604
  # connect to database
605
  my $dbh = $form->get_standard_dbh;
604
  my $dbh = SL::DB->client->dbh;
606 605

  
607 606
  my $last_period     = 0;
608 607
  my $category        = "pos_ustva";
......
704 703
  $form->{"Z65"} = $form->{"Z62"}     - $form->{"69"};
705 704
  $form->{"83"}  = $form->{"Z65"}     - $form->{"39"};
706 705

  
707
  $dbh->disconnect;
708

  
709 706
  $main::lxdebug->leave_sub();
710 707
}
711 708

  

Auch abrufbar als: Unified diff