Improve dsn string logic

This commit is contained in:
Timothy Warren 2012-03-29 07:39:04 -04:00
parent 42273c43aa
commit b241819799
1 changed files with 4 additions and 6 deletions

View File

@ -82,13 +82,11 @@ class Query_Builder {
switch($dbtype)
{
default:
$dsn = "host={$params->host};dbname={$params->database}";
if ( ! empty($params->port))
{
$dsn = "host={$params->host};port={$params->port};dbname={$params->database}";
}
else
{
$dsn = "host={$params->host};dbname={$params->database}";
$dsn .= ";port={$params->port}";
}
break;
@ -102,7 +100,7 @@ class Query_Builder {
}
// Create the database connection
if ( ! empty($params->user) && $db_type !== 'sqlite')
if ( ! empty($params->user))
{
$this->db = new $dbtype($dsn, $params->user, $params->pass);
}