Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 53cbf0de

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

  • ID 53cbf0de16033a5d035feb9dc678e3cecb4d39b9
  • Vorgänger d38eaef8
  • Nachfolger 180163aa

get_standard_dbh entfernt und auf SL::DB->client->dbh umgebogen

Unterschiede anzeigen:

SL/DBUpgrade2.pm
243 243
  $dbh->begin_work;
244 244

  
245 245
  # setup dbup_ export vars & run script
246
  my $old_dbh       = $::form->set_standard_dbh($dbh);
246
  my $old_dbh       = SL::DB->client->dbh($dbh);
247 247
  my %dbup_myconfig = map { ($_ => $::form->{$_}) } qw(dbname dbuser dbpasswd dbhost dbport dbconnect);
248 248
  my $result        = eval {
249 249
    SL::DBUpgrade2::Base::execute_script(
SL/Form.pm
85 85

  
86 86
use strict;
87 87

  
88
my $standard_dbh;
89

  
90
END {
91
  disconnect_standard_dbh();
92
}
93

  
94
sub disconnect_standard_dbh {
95
  return unless $standard_dbh;
96

  
97
  $standard_dbh->rollback();
98
  undef $standard_dbh;
99
}
100

  
101 88
sub read_version {
102 89
  my ($self) = @_;
103 90

  
......
1388 1375
}
1389 1376

  
1390 1377
# Database routines used throughout
1378
# DB Handling got moved to SL::DB, these are only shims for compatibility
1391 1379

  
1392 1380
sub dbconnect {
1393
  $main::lxdebug->enter_sub(2);
1394

  
1395
  my ($self, $myconfig) = @_;
1396

  
1397
  # connect to database
1398
  my $dbh = SL::DBConnect->connect or $self->dberror;
1399

  
1400
  # set db options
1401
  if ($myconfig->{dboptions}) {
1402
    $dbh->do($myconfig->{dboptions}) || $self->dberror($myconfig->{dboptions});
1403
  }
1404

  
1405
  $main::lxdebug->leave_sub(2);
1406

  
1407
  return $dbh;
1408
}
1409

  
1410
sub dbconnect_noauto {
1411
  $main::lxdebug->enter_sub();
1412

  
1413
  my ($self, $myconfig) = @_;
1414

  
1415
  # connect to database
1416
  my $dbh = SL::DBConnect->connect(SL::DBConnect->get_connect_args(AutoCommit => 0)) or $self->dberror;
1417

  
1418
  # set db options
1419
  if ($myconfig->{dboptions}) {
1420
    $dbh->do($myconfig->{dboptions}) || $self->dberror($myconfig->{dboptions});
1421
  }
1422

  
1423
  $main::lxdebug->leave_sub();
1424

  
1425
  return $dbh;
1381
  SL::DB->client->dbh;
1426 1382
}
1427 1383

  
1428 1384
sub get_standard_dbh {
1429
  $main::lxdebug->enter_sub(2);
1385
  my $dbh = SL::DB->client->dbh;
1430 1386

  
1431
  my $self     = shift;
1432
  my $myconfig = shift || \%::myconfig;
1433

  
1434
  if ($standard_dbh && !$standard_dbh->{Active}) {
1435
    $main::lxdebug->message(LXDebug->INFO(), "get_standard_dbh: \$standard_dbh is defined but not Active anymore");
1436
    undef $standard_dbh;
1387
  if ($dbh && !$dbh->{Active}) {
1388
    $main::lxdebug->message(LXDebug->INFO(), "get_standard_dbh: \$dbh is defined but not Active anymore");
1389
    SL::DB->client->dbh(undef);
1437 1390
  }
1438 1391

  
1439
  $standard_dbh ||= SL::DB->client->dbh;
1440

  
1441
  $main::lxdebug->leave_sub(2);
1442

  
1443
  return $standard_dbh;
1392
  SL::DB->client->dbh;
1444 1393
}
1445 1394

  
1446
sub set_standard_dbh {
1447
  my ($self, $dbh) = @_;
1448
  my $old_dbh      = $standard_dbh;
1449
  $standard_dbh    = $dbh;
1450

  
1451
  return $old_dbh;
1395
sub disconnect_standard_dbh {
1396
  SL::DB->client->dbh->rollback;
1452 1397
}
1453 1398

  
1399
# /database
1400

  
1454 1401
sub date_closed {
1455 1402
  $main::lxdebug->enter_sub();
1456 1403

  

Auch abrufbar als: Unified diff