Merge pull request #1 from josh4trunks/patch-1

Support user defined MySQL Port/Socket in API
This commit is contained in:
Isaac Connor 2016-05-10 14:13:51 -04:00
commit e804cfbc16
1 changed files with 14 additions and 1 deletions

View File

@ -67,7 +67,6 @@ class DATABASE_CONFIG {
public $default = array( public $default = array(
'datasource' => 'Database/Mysql', 'datasource' => 'Database/Mysql',
'persistent' => false, 'persistent' => false,
'host' => ZM_DB_HOST,
'login' => ZM_DB_USER, 'login' => ZM_DB_USER,
'password' => ZM_DB_PASS, 'password' => ZM_DB_PASS,
'database' => ZM_DB_NAME, 'database' => ZM_DB_NAME,
@ -85,4 +84,18 @@ class DATABASE_CONFIG {
'prefix' => '', 'prefix' => '',
//'encoding' => 'utf8', //'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;
}
} }