Reapply changes to Database.pm

This commit is contained in:
josh4trunks 2016-05-22 08:19:18 -07:00
parent 2ab79820a1
commit 38e1cc909c
1 changed files with 17 additions and 13 deletions

View File

@ -79,25 +79,29 @@ sub zmDbConnect
}
if ( !defined( $dbh ) )
{
my ( $host, $port ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
my $socket;
my ( $host, $portOrSocket ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
if ( defined($port) )
if ( defined($portOrSocket) )
{
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.";host=".$host
.";port=".$port
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
);
if ( $portOrSocket =~ /^\// )
{
$socket = ";mysql_socket=".$portOrSocket;
}
else
{
$socket = ";host=".$host.";port=".$portOrSocket;
}
}
else
{
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.";host=".$Config{ZM_DB_HOST}
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
);
$socket = ";host=".$Config{ZM_DB_HOST};
}
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.$socket
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
);
$dbh->trace( 0 );
}
return( $dbh );