MongoDB\Driver\Manager::selectServer
Select a server matching a read preference
Beschreibung
final public MongoDB\Driver\Server MongoDB\Driver\Manager::selectServer
( MongoDB\Driver\ReadPreference $readPreference
)
Hinweis:
Unlike MongoDB\Driver\Manager::getServers, this method
will initialize database connections and perform server discovery if
necessary. See the
» Server Selection Specification
for additional information.
Parameter-Liste
-
readPreference
-
Optionally, a MongoDB\Driver\ReadPreference to route the command to. If none given, defaults to the Read Preferences set by the MongoDB Connection URI.
Rückgabewerte
Returns an MongoDB\Driver\Server matching the read preference.
Fehler/Exceptions
- Throws MongoDB\Driver\AuthenticationException if authentication is needed and fails
- Throws MongoDB\Driver\ConnectionException if connection to the server fails for other then authentication reasons
- Throws MongoDB\Driver\Exception\RuntimeException if a server matching the read preference could not be found.