instead of code duplication for opening the db, use zmDbConnect everywhere

This commit is contained in:
Isaac Connor 2016-05-03 08:59:40 -04:00
parent 55d58a140e
commit 30f34a6f49
1 changed files with 2 additions and 7 deletions

View File

@ -30,6 +30,7 @@ use warnings;
require Exporter;
require ZoneMinder::Base;
require ZoneMinder::Database;
our @ISA = qw(Exporter ZoneMinder::Base);
@ -82,12 +83,7 @@ BEGIN
}
close( $CONFIG );
use DBI;
my $dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.";host=".$Config{ZM_DB_HOST}
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
) or croak( "Can't connect to db" );
my $dbh = zmDbConnect() or croak( "Can't connect to db" );
my $sql = 'select * from Config';
my $sth = $dbh->prepare_cached( $sql ) or croak( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or croak( "Can't execute: ".$sth->errstr() );
@ -95,7 +91,6 @@ BEGIN
$Config{$config->{Name}} = $config->{Value};
}
$sth->finish();
#$dbh->disconnect();
if ( ! exists $Config{ZM_SERVER_ID} ) {
$Config{ZM_SERVER_ID} = undef;