mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-22 01:30:23 +08:00
Mongo Connection updated allowing to fetch default database name from options.
This commit is contained in:
@@ -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.");
|
||||
|
||||
Reference in New Issue
Block a user