Mongo Connection updated allowing to fetch default database name from options.

This commit is contained in:
Paul Klimov
2013-11-27 12:00:32 +02:00
parent 6eeeb6d169
commit ec2df146a8
3 changed files with 10 additions and 4 deletions

View File

@@ -85,7 +85,9 @@ class Connection extends Component
protected function fetchDefaultDatabaseName()
{
if ($this->defaultDatabaseName === null) {
if (preg_match('/^mongodb:\\/\\/.+\\/(.+)$/s', $this->dsn, $matches)) {
if (isset($this->options['db'])) {
$this->defaultDatabaseName = $this->options['db'];
} elseif (preg_match('/^mongodb:\\/\\/.+\\/(.+)$/s', $this->dsn, $matches)) {
$this->defaultDatabaseName = $matches[1];
} else {
throw new InvalidConfigException("Unable to determine default database name from dsn.");