Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 040aa711

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

  • ID 040aa711a11c32b18e08f048a4014310bddf074f
  • Vorgänger 39be0a81
  • Nachfolger e8784e42

DATEV: single-dbh

Unterschiede anzeigen:

SL/DATEV.pm
31 31

  
32 32
use SL::DBUtils;
33 33
use SL::DATEV::KNEFile;
34
use SL::DB;
34 35

  
35 36
use Data::Dumper;
36 37
use DateTime;
......
233 234
    $self->{provided_dbh} = 1;
234 235
  }
235 236

  
236
  $self->{dbh} ||= $::form->get_standard_dbh;
237
  $self->{dbh} ||= SL::DB->client->dbh;
237 238
}
238 239

  
239 240
sub provided_dbh {
......
285 286
sub save_datev_stamm {
286 287
  my ($self, $data) = @_;
287 288

  
288
  do_query($::form, $self->dbh, 'DELETE FROM datev');
289
  SL::DB->client->with_transaction(sub {
290
    do_query($::form, $self->dbh, 'DELETE FROM datev');
289 291

  
290
  my @columns = qw(beraternr beratername dfvkz mandantennr datentraegernr abrechnungsnr);
292
    my @columns = qw(beraternr beratername dfvkz mandantennr datentraegernr abrechnungsnr);
291 293

  
292
  my $query = "INSERT INTO datev (" . join(', ', @columns) . ") VALUES (" . join(', ', ('?') x @columns) . ")";
293
  do_query($::form, $self->dbh, $query, map { $data->{$_} } @columns);
294

  
295
  $self->dbh->commit unless $self->provided_dbh;
294
    my $query = "INSERT INTO datev (" . join(', ', @columns) . ") VALUES (" . join(', ', ('?') x @columns) . ")";
295
    do_query($::form, $self->dbh, $query, map { $data->{$_} } @columns);
296
  });
296 297
}
297 298

  
298 299
sub export {
......
1237 1238
Set a database handle to use in the process. This allows for an export to be
1238 1239
done on a transaction in progress without committing first.
1239 1240

  
1241
Note: If you don't want this code to commit, simply providing a dbh is not
1242
enough enymore. You'll have to wrap the call into a transaction yourself, so
1243
that the internal transaction does not commit.
1244

  
1240 1245
=item exporttype
1241 1246

  
1242 1247
See L<CONSTANTS> for possible values. This MUST be set before export is called.

Auch abrufbar als: Unified diff