diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm index 8b983bfc9..8fd494b96 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm @@ -31,7 +31,7 @@ use warnings; require ZoneMinder::Base; require Date::Manip; -use parent qw(ZoneMinder::Object);; +use parent qw(ZoneMinder::Object); #our @ISA = qw(ZoneMinder::Object); use vars qw/ $table $primary_key /; @@ -114,8 +114,8 @@ sub Execute { $sql =~ s/zmSystemLoad/$load/g; } - my $sth = $$self{dbh}->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$$self{dbh}->errstr() ); + my $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() ); my $res = $sth->execute(); if ( !$res ) { diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Object.pm b/scripts/ZoneMinder/lib/ZoneMinder/Object.pm index 147d5928c..379aab045 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Object.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Object.pm @@ -49,6 +49,12 @@ sub new { my $self = {}; bless $self, $parent; + no strict 'refs'; + my $primary_key = ${$parent.'::primary_key'}; + if ( ! $primary_key ) { + Error( 'NO primary_key for type ' . $parent ); + return; + } # end if if ( ( $$self{$primary_key} = $id ) or $data ) { #$log->debug("loading $parent $id") if $debug or DEBUG_ALL; $self->load( $data );