public function parseDSN($dsnStr)
{
if (empty($dsnStr)) {
return false;
}
$info = parse_url($dsnStr);
if ($info['scheme']) {
$dsn = array('dbms' => $info['scheme'], 'username' => isset($info['user']) ? $info['user'] : '', 'password' => isset($info['pass']) ? $info['pass'] : '', 'hostname' => isset($info['host']) ? $info['host'] : '', 'hostport' => isset($info['port']) ? $info['port'] : '', 'database' => isset($info['path']) ? substr($info['path'], 1) : '');
} else {
preg_match('/^(.*?)\\:\\/\\/(.*?)\\:(.*?)\\@(.*?)\\:([0-9]{1, 6})\\/(.*?)$/', trim($dsnStr), $matches);
$dsn = array('dbms' => $matches[1], 'username' => $matches[2], 'password' => $matches[3], 'hostname' => $matches[4], 'hostport' => $matches[5], 'database' => $matches[6]);
}
return $dsn;
}