config = $config; } public function set_config($group = 'default') { if ( ! isset($this->config[$group])) { throw new InvalidArgumentException('Group '.$group.' not exists'); } if ( ! empty($this->config[$group]['dsn'])) { $dsn = $this->config[$group]['dsn']; } else { $config = $this->config[$group]; $dsn = $config['dbdriver'].'://'.$config['username'].':'.$config['password'] .'@'.$config['hostname'].'/'.$config['database']; } $params = array_slice($this->config[$group], 6); return $dsn.http_build_query($params); } }