|
The MongoDB\Driver\Manager classIntroductionThe MongoDB\Driver\Manager is the main entry point to the extension. It is responsible for maintaining connections to MongoDB (be it standalone server, replica set, or sharded cluster). No connection to MongoDB is made upon instantiating the Manager. This means the MongoDB\Driver\Manager can always be constructed, even though one or more MongoDB servers are down. Any write or query can throw connection exceptions as connections are created lazily. A MongoDB server may also become unavailable during the life time of the script. It is therefore important that all actions on the Manager to be wrapped in try/catch statements. Class synopsisMongoDB\Driver\Manager
final
class MongoDB\Driver\Manager
{
/* Methods */
final public void addSubscriber(MongoDB\Driver\Monitoring\Subscriber
$subscriber )final public __construct(stringnull
$uri = null , arraynull $uriOptions = null , arraynull $driverOptions = null )final public MongoDB\Driver\ClientEncryption createClientEncryption(array
$options )final public MongoDB\Driver\WriteResult executeBulkWrite(string
$namespace , MongoDB\Driver\BulkWrite $bulk , arrayMongoDB\Driver\WriteConcernnull $options = null )final public MongoDB\Driver\Cursor executeCommand(string
$db , MongoDB\Driver\Command $command , arrayMongoDB\Driver\ReadPreferencenull $options = null )final public MongoDB\Driver\Cursor executeQuery(string
$namespace , MongoDB\Driver\Query $query , arrayMongoDB\Driver\ReadPreferencenull $options = null )final public MongoDB\Driver\Cursor executeReadCommand(string
$db , MongoDB\Driver\Command $command , arraynull $options = null )final public MongoDB\Driver\Cursor executeReadWriteCommand(string
$db , MongoDB\Driver\Command $command , arraynull $options = null )final public MongoDB\Driver\Cursor executeWriteCommand(string
$db , MongoDB\Driver\Command $command , arraynull $options = null )final public arrayobjectnull getEncryptedFieldsMap()
final public MongoDB\Driver\ReadConcern getReadConcern()
final public MongoDB\Driver\ReadPreference getReadPreference()
final public array getServers()
final public MongoDB\Driver\WriteConcern getWriteConcern()
final public void removeSubscriber(MongoDB\Driver\Monitoring\Subscriber
$subscriber )final public MongoDB\Driver\Server selectServer(MongoDB\Driver\ReadPreferencenull
$readPreference = null )final public MongoDB\Driver\Session startSession(arraynull
}$options = null )ExamplesExample #1 MongoDB\Driver\Manager::__construct basic example var_dumping a MongoDB\Driver\Manager will print out various details about the manager that are otherwise not normally exposed. This can be useful to debug how the driver views your MongoDB setup, and which options are used.
The above example will output something similar to: object(MongoDB\Driver\Manager)#1 (2) { ["uri"]=> string(26) "mongodb://127.0.0.1:27017/" ["cluster"]=> array(0) { } }
|