MONGODBDRIVERSERVER(3) 1 MONGODBDRIVERSERVER(3)The MongoDBDriverServer class
INTRODUCTION CLASS SYNOPSIS
MongoDBver
final
MongoDBver
Constants
o const integer$MongoDBver::TYPE_MONGOS1
o const integer$MongoDBver::TYPE_STANDALONE2
o const integer$MongoDBver::TYPE_ARBITER3
o const integer$MongoDBver::TYPE_SECONDARY4
o const integer$MongoDBver::TYPE_PRIMARY5
Methods
o finalpublic MongoDBDriverServer::__construct (string $host, string $port, [array $options], [array $driverOptions])
o finalpublic ReturnType MongoDBDriverServer::executeBulkWrite (string $namespace, BulkWrite $zwrite)
o finalpublic ReturnType MongoDBDriverServer::executeCommand (string $db, Command $command)
o finalpublic ReturnType MongoDBDriverServer::executeQuery (string $namespace, Query $zquery)
o finalpublic ReturnType MongoDBDriverServer::getHost (void )
o finalpublic ReturnType MongoDBDriverServer::getInfo (void )
o finalpublic ReturnType MongoDBDriverServer::getLatency (void )
o finalpublic ReturnType MongoDBDriverServer::getPort (void )
o finalpublic ReturnType MongoDBDriverServer::getState (void )
o finalpublic ReturnType MongoDBDriverServer::getType (void )
o finalpublic ReturnType MongoDBDriverServer::isDelayed (void )
o finalpublic ReturnType MongoDBDriverServer::isPassive (void )
PREDEFINED CONSTANTS
o MongoDBDriverServer::TYPE_MONGOS -
o MongoDBDriverServer::TYPE_STANDALONE -
o MongoDBDriverServer::TYPE_ARBITER -
o MongoDBDriverServer::TYPE_SECONDARY -
o MongoDBDriverServer::TYPE_PRIMARY -
PHP Documentation Group MONGODBDRIVERSERVER(3)
Check Out this Related Man Page
MONGODBDRIVERMANAGER(3) 1 MONGODBDRIVERMANAGER(3)The MongoDBDriverManager class
INTRODUCTION
The MongoDBDriverManager 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 MongoDBDriverManager 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 SYNOPSIS
MongoDBnager
final
MongoDBnager
Methods
o finalpublic MongoDBDriverManager::__construct (string $uri, [array $options], [array $driverOptions])
o finalpublic MongoDBDriverWriteResult MongoDBDriverManager::executeBulkWrite (string $namespace, MongoDB0lk, [MongoDBWriteConcern
$writeConcern])
o finalpublic MongoDBDriverCursor MongoDBDriverManager::executeCommand (string $db, MongoDB $command, [MongoDBreadPreference])
o finalpublic MongoDBDriverWriteResult MongoDBDriverManager::executeDelete (string $namespace, array|object $filter, [array $dele-
teOptions], [MongoDBWriteConcern $writeConcern])
o finalpublic MongoDBDriverWriteResult MongoDBDriverManager::executeInsert (string $namespace, array|object $document, [MongoDB-
WriteConcern $writeConcern])
o finalpublic MongoDBDriverCursor MongoDBDriverManager::executeQuery (string $namespace, MongoDBQuery $query, [MongoDBreadPrefer-
ence])
o finalpublic MongoDBDriverWriteResult MongoDBDriverManager::executeUpdate (string $namespace, array|object $filter, array|object
$newObj, [array $updateOptions], [MongoDBWriteConcern $writeConcern])
o finalpublic ReturnType MongoDBDriverManager::getServers (void )
o finalpublic MongoDBDriverServer MongoDBDriverManager::selectServer (MongoDBreadPreference)
EXAMPLES
Example #1
MongoDBDriverManager.__construct(3) basic example
var_dump(3)ing a MongoDBDriverManager will print out various details about the manager that are otherwise not normally expopsed.
This can be useful to debug how the driver views your MongoDB setup, and which options are used.
<?php
$manager = new MongoDBDriverManager("mongodb://localhost:27017");
var_dump($manager);
?>
The above example will output something similar to:
object(MongoDBDriverManager)#1(3) {
["request_id"]=>
int(1714636915)
["uri"]=>
string(25) "mongodb://localhost:27017"
["cluster"]=>
array(13) {
["mode"]=>
string(6) "direct"
["state"]=>
string(4) "born"
["request_id"]=>
int(0)
["sockettimeoutms"]=>
int(300000)
["last_reconnect"]=>
int(0)
["uri"]=>
string(25) "mongodb://localhost:27017"
["requires_auth"]=>
int(0)
["nodes"]=>
array(...)
["max_bson_size"]=>
int(16777216)
["max_msg_size"]=>
int(50331648)
["sec_latency_ms"]=>
int(15)
["peers"]=>
array(0) {
}
["replSet"]=>
NULL
}
}
PHP Documentation Group MONGODBDRIVERMANAGER(3)