Skip to content

Commit

Permalink
Merge pull request #1 from josh4trunks/patch-1
Browse files Browse the repository at this point in the history
Support user defined MySQL Port/Socket in API
  • Loading branch information
connortechnology committed May 10, 2016
2 parents ce69f24 + e121604 commit e804cfb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion web/api/app/Config/database.php.default
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => ZM_DB_HOST,
'login' => ZM_DB_USER,
'password' => ZM_DB_PASS,
'database' => ZM_DB_NAME,
Expand All @@ -85,4 +84,18 @@ class DATABASE_CONFIG {
'prefix' => '',
//'encoding' => 'utf8',
);

public function __construct() {
if (strpos(ZM_DB_HOST, ':')):
$array = explode(':', ZM_DB_HOST, 2);
if (is_numeric($array[1])):
$this->default['host'] = $array[0];
$this->default['port'] = $array[1];
else:
$this->default['unix_socket'] = $array[1];
endif;
else:
$this->default['host'] = ZM_DB_HOST;
endif;
}
}

0 comments on commit e804cfb

Please sign in to comment.