Skip to content

Commit

Permalink
Updated the getDefaultDatabaseName to include SRV support as per yiis…
Browse files Browse the repository at this point in the history
  • Loading branch information
kublermdk committed Oct 28, 2019
1 parent 99e0208 commit 925afd3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ public function setDefaultDatabaseName($name)
public function getDefaultDatabaseName()
{
if ($this->_defaultDatabaseName === null) {
if (preg_match('/^mongodb:\\/\\/.+\\/([^?&]+)/s', $this->dsn, $matches)) {
$this->_defaultDatabaseName = $matches[1];
if (preg_match('/^mongodb(:|\+srv:)\\/\\/.+\\/([^?&]+)/s', $this->dsn, $matches)) {
$this->_defaultDatabaseName = $matches[2];
} else {
throw new InvalidConfigException("Unable to determine default database name from dsn.");
}
Expand Down

0 comments on commit 925afd3

Please sign in to comment.