Merge branch 'merge_db_connects' into storageareas

This commit is contained in:
Isaac Connor 2016-05-03 14:09:18 -04:00
commit 18442be77f
4 changed files with 14 additions and 5 deletions

View File

@ -81,6 +81,13 @@ our @EXPORT = ( @EXPORT_OK );
our $VERSION = $ZoneMinder::Base::VERSION; our $VERSION = $ZoneMinder::Base::VERSION;
BEGIN {
require ZoneMinder::Config;
require ZoneMinder::Database;
ZoneMinder::Config::zmConfigLoad();
ZoneMinder::Database::zmDbConnect();
}
1; 1;
__END__ __END__

View File

@ -30,7 +30,6 @@ use warnings;
require Exporter; require Exporter;
require ZoneMinder::Base; require ZoneMinder::Base;
require ZoneMinder::Database;
our @ISA = qw(Exporter ZoneMinder::Base); our @ISA = qw(Exporter ZoneMinder::Base);
@ -64,8 +63,9 @@ use constant ZM_CONFIG => "@ZM_CONFIG@"; # Path to the ZoneMinder config file
use Carp; use Carp;
# Load the config from the database into the symbol table # Load the config from the database into the symbol table
BEGIN sub zmConfigLoad {
{ %Config = ();
my $config_file = ZM_CONFIG; my $config_file = ZM_CONFIG;
open( my $CONFIG, "<", $config_file ) open( my $CONFIG, "<", $config_file )
or croak( "Can't open config file '$config_file': $!" ); or croak( "Can't open config file '$config_file': $!" );
@ -83,7 +83,8 @@ BEGIN
} }
close( $CONFIG ); close( $CONFIG );
my $dbh = zmDbConnect() or croak( "Can't connect to db" ); require ZoneMinder::Database;
my $dbh = ZoneMinder::Database::zmDbConnect() or croak( "Can't connect to db" );
my $sql = 'select * from Config'; my $sql = 'select * from Config';
my $sth = $dbh->prepare_cached( $sql ) or croak( "Can't prepare '$sql': ".$dbh->errstr() ); 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() ); my $res = $sth->execute() or croak( "Can't execute: ".$sth->errstr() );

View File

@ -27,6 +27,7 @@ package ZoneMinder::Database;
use 5.006; use 5.006;
use strict; use strict;
use warnings; use warnings;
use DBI;
require Exporter; require Exporter;
require ZoneMinder::Base; require ZoneMinder::Base;

View File

@ -461,7 +461,7 @@ sub databaseLevel
{ {
if ( !$this->{dbh} ) if ( !$this->{dbh} )
{ {
$this->{dbh} = zmDbConnect(); $this->{dbh} = ZoneMinder::Database::zmDbConnect();
if ( !$this->{dbh} ) if ( !$this->{dbh} )
{ {
$databaseLevel = NOLOG; $databaseLevel = NOLOG;