diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Database.pm b/scripts/ZoneMinder/lib/ZoneMinder/Database.pm index 19a5f8662..8be04ee99 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Database.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Database.pm @@ -77,39 +77,39 @@ sub zmDbConnect { } my $options = shift; - if ( ( ! defined( $dbh ) ) or ! $dbh->ping() ) { + if ( ( !defined($dbh) ) or ! $dbh->ping() ) { my ( $host, $portOrSocket ) = ( $ZoneMinder::Config::Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ ); my $socket; if ( defined($portOrSocket) ) { if ( $portOrSocket =~ /^\// ) { - $socket = ";mysql_socket=".$portOrSocket; + $socket = ';mysql_socket='.$portOrSocket; } else { - $socket = ";host=".$host.";port=".$portOrSocket; + $socket = ';host='.$host.';port='.$portOrSocket; } } else { - $socket = ";host=".$Config{ZM_DB_HOST}; + $socket = ';host='.$Config{ZM_DB_HOST}; } - my $sslOptions = ""; + my $sslOptions = ''; if ( $Config{ZM_DB_SSL_CA_CERT} ) { $sslOptions = ';'.join(';', - "mysql_ssl=1", - "mysql_ssl_ca_file=".$Config{ZM_DB_SSL_CA_CERT}, - "mysql_ssl_client_key=".$Config{ZM_DB_SSL_CLIENT_KEY}, - "mysql_ssl_client_cert=".$Config{ZM_DB_SSL_CLIENT_CERT} + 'mysql_ssl=1', + 'mysql_ssl_ca_file='.$Config{ZM_DB_SSL_CA_CERT}, + 'mysql_ssl_client_key='.$Config{ZM_DB_SSL_CLIENT_KEY}, + 'mysql_ssl_client_cert='.$Config{ZM_DB_SSL_CLIENT_CERT} ); } - $dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME} + $dbh = DBI->connect( 'DBI:mysql:database='.$Config{ZM_DB_NAME} .$socket . $sslOptions . ($options?';'.join(';', map { $_.'='.$$options{$_} } keys %{$options} ) : '' ) , $Config{ZM_DB_USER} , $Config{ZM_DB_PASS} ); - $dbh->trace( 0 ); + $dbh->trace(0) if $dbh; } - return( $dbh ); -} + return $dbh; +} # end sub zmDbConnect sub zmDbDisconnect { if ( defined( $dbh ) ) {