public function __construct($dsn)
{
$array = parse_url($dsn);
if (isset($array['query'])) {
parse_str($array['query'], $this->params);
}
// process params that are named the same as props
foreach (array('scheme', 'host', 'port', 'user', 'pass') as $p) {
if (isset($array[$p])) {
$this->{$p} = $array[$p];
}
}
if (isset($array['path'])) {
$this->database = basename($array['path']);
}
}