Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 09372651

Von Sven Schöling vor mehr als 8 Jahren hinzugefügt

  • ID 09372651092644b1b852b8fea775003d92e2d08c
  • Vorgänger 800378d4
  • Nachfolger 16c60c08

GL: single-dbh

Unterschiede anzeigen:

SL/GL.pm
42 42
use SL::DATEV qw(:CONSTANTS);
43 43
use SL::DBUtils;
44 44
use SL::Util qw(trim);
45
use SL::DB;
45 46

  
46 47
use strict;
47 48

  
......
49 50
  my ($self, $myconfig, $form) = @_;
50 51
  $main::lxdebug->enter_sub();
51 52

  
52
  # connect to database
53
  my $dbh = $form->dbconnect_noauto($myconfig);
54

  
55
  # acc_trans entries are deleted by database triggers.
56
  do_query($form, $dbh, qq|DELETE FROM gl WHERE id = ?|, conv_i($form->{id}));
53
  SL::DB->with_transaction(sub {
54
    do_query($form, SL::DB->client->dbh, qq|DELETE FROM gl WHERE id = ?|, conv_i($form->{id}));
55
  });
57 56

  
58
  # commit and redirect
59
  my $rc = $dbh->commit;
60
  $dbh->disconnect;
61 57
  $main::lxdebug->leave_sub();
58
}
62 59

  
63
  $rc;
60
sub post_transaction {
61
  my ($self, $myconfig, $form) = @_;
62
  $main::lxdebug->enter_sub();
63

  
64
  my $rc = SL::DB->client->with_transaction(\&_post_transaction, $self, $myconfig, $form);
64 65

  
66
  $::lxdebug->leave_sub;
67
  return $rc;
65 68
}
66 69

  
67
sub post_transaction {
70
sub _post_transaction {
68 71
  my ($self, $myconfig, $form) = @_;
69 72
  $main::lxdebug->enter_sub();
70 73

  
......
73 76

  
74 77
  my $i;
75 78

  
76
  # connect to database, turn off AutoCommit
77
  my $dbh = $form->dbconnect_noauto($myconfig);
79
  my $dbh = SL::DB->client->dbh;
78 80

  
79 81
  # post the transaction
80 82
  # make up a unique handle and store in reference field
......
203 205
    $datev->export;
204 206

  
205 207
    if ($datev->errors) {
206
      $dbh->rollback;
207 208
      die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors;
208 209
    }
209 210
  }
210 211

  
211
  # commit and redirect
212
  my $rc = $dbh->commit;
213
  $dbh->disconnect;
214
  $main::lxdebug->leave_sub();
215

  
216
  return $rc;
212
  return 1;
217 213
}
218 214

  
219 215
sub all_transactions {
......
710 706
}
711 707

  
712 708
sub storno {
709
  my ($self, $form, $myconfig, $id) = @_;
713 710
  $main::lxdebug->enter_sub();
714 711

  
712
  my $rc = SL::DB->client->with_transaction(\&_storno, $self, $form, $myconfig, $id);
713

  
714
  $::lxdebug->leave_sub;
715
  return $rc;
716
}
717

  
718
sub _storno {
715 719
  my ($self, $form, $myconfig, $id) = @_;
716 720

  
717 721
  my ($query, $new_id, $storno_row, $acc_trans_rows);
718
  my $dbh = $form->get_standard_dbh($myconfig);
722
  my $dbh = SL::DB->client->dbh;
719 723

  
720 724
  $query = qq|SELECT nextval('glid')|;
721 725
  ($new_id) = selectrow_query($form, $dbh, $query);
......
752 756
    do_query($form, $dbh, $query, (values %$row));
753 757
  }
754 758

  
755
  $dbh->commit;
756

  
757
  $main::lxdebug->leave_sub();
759
  return 1;
758 760
}
759 761

  
760 762
sub get_chart_balances {

Auch abrufbar als: Unified diff