merge from SA. Adds the ability to pass in additional options when connecting

This commit is contained in:
Isaac Connor 2017-05-20 10:32:41 -04:00
parent d76d65f475
commit dbf83831ff
1 changed files with 5 additions and 3 deletions

View File

@ -75,9 +75,11 @@ sub zmDbConnect {
if ( $force ) {
zmDbDisconnect();
}
if ( !defined( $dbh ) ) {
my $options = shift;
if ( ( ! defined( $dbh ) ) or ! $dbh->ping() ) {
my ( $host, $portOrSocket ) = ( $ZoneMinder::Config::Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
my $socket;
my ( $host, $portOrSocket ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
if ( defined($portOrSocket) ) {
if ( $portOrSocket =~ /^\// ) {
@ -89,7 +91,7 @@ sub zmDbConnect {
$socket = ";host=".$Config{ZM_DB_HOST};
}
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.$socket
.$socket . ($options?';'.join(';', map { $_.'='.$$options{$_} } keys %{$options} ) : '' )
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
);