Revision 96670fe8
Von Moritz Bunkus vor etwa 8 Jahren hinzugefügt
SL/Controller/CustomerVendor.pm | ||
---|---|---|
152 | 152 |
|
153 | 153 |
my $db = $self->{cv}->db; |
154 | 154 |
|
155 |
$db->do_transaction(sub {
|
|
155 |
$db->with_transaction(sub {
|
|
156 | 156 |
my $cvs_by_nr; |
157 | 157 |
if ( $self->is_vendor() ) { |
158 | 158 |
if ( $self->{cv}->vendornumber ) { |
... | ... | |
223 | 223 |
$note->delete(cascade => 'delete'); |
224 | 224 |
} |
225 | 225 |
} |
226 |
|
|
227 |
1; |
|
226 | 228 |
}) || die($db->error); |
227 | 229 |
|
228 | 230 |
} |
... | ... | |
351 | 353 |
$self->action_edit(); |
352 | 354 |
} else { |
353 | 355 |
|
354 |
$db->do_transaction(sub {
|
|
356 |
$db->with_transaction(sub {
|
|
355 | 357 |
$self->{cv}->delete(cascade => 1); |
356 | 358 |
|
357 | 359 |
my $snumbers = $self->is_vendor() ? 'vendornumber_'. $self->{cv}->vendornumber : 'customernumber_'. $self->{cv}->customernumber; |
... | ... | |
379 | 381 |
SL::Helper::Flash::flash('error', $::locale->text('No contact selected to delete')); |
380 | 382 |
} else { |
381 | 383 |
|
382 |
$db->do_transaction(sub {
|
|
384 |
$db->with_transaction(sub {
|
|
383 | 385 |
if ( $self->{contact}->used ) { |
384 | 386 |
$self->{contact}->detach(); |
385 | 387 |
$self->{contact}->save(); |
... | ... | |
388 | 390 |
$self->{contact}->delete(cascade => 1); |
389 | 391 |
SL::Helper::Flash::flash('info', $::locale->text('Contact deleted.')); |
390 | 392 |
} |
393 |
|
|
394 |
1; |
|
391 | 395 |
}) || die($db->error); |
392 | 396 |
|
393 | 397 |
$self->{contact} = $self->_new_contact_object; |
... | ... | |
405 | 409 |
SL::Helper::Flash::flash('error', $::locale->text('No shipto selected to delete')); |
406 | 410 |
} else { |
407 | 411 |
|
408 |
$db->do_transaction(sub {
|
|
412 |
$db->with_transaction(sub {
|
|
409 | 413 |
if ( $self->{shipto}->used ) { |
410 | 414 |
$self->{shipto}->detach(); |
411 | 415 |
$self->{shipto}->save(cascade => 1); |
... | ... | |
414 | 418 |
$self->{shipto}->delete(cascade => 1); |
415 | 419 |
SL::Helper::Flash::flash('info', $::locale->text('Shipto deleted.')); |
416 | 420 |
} |
421 |
|
|
422 |
1; |
|
417 | 423 |
}) || die($db->error); |
418 | 424 |
|
419 | 425 |
$self->{shipto} = SL::DB::Shipto->new(); |
Auch abrufbar als: Unified diff
»with_transaction« anstelle von »do_transaction« verwenden
Es sollte so selten wie möglich »do_transaction« verwndet werden, damit
man sich immer angewöhnt, »with_transaction« zu nutzen.
Hintergründe und Unterschiede zwischen den beiden Funktionen sind in der
Dokumentation von SL/DB.pm beschrieben.