Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mongodbdrivermanager(3) [php 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)

Check Out this Related Man Page

MONGOCLIENT(3)								 1							    MONGOCLIENT(3)

The MongoClient class

INTRODUCTION
A connection manager for PHP and MongoDB. This class is used to create and manage connections. A typical use is: Example #1 MongoClient basic usage <?php $m = new MongoClient(); // connect $db = $m->foo; // get the database named "foo" ?> See MongoClient.__construct(3) and the section on connecting for more information about creating connections. CLASS SYNOPSIS
MongoClient MongoClient Constants o const string$MongoClient::VERSION o const string$MongoClient::DEFAULT_HOST"localhost" o const int$MongoClient::DEFAULT_PORT27017 o const string$MongoClient::RP_PRIMARY"primary" o const string$MongoClient::RP_PRIMARY_PREFERRED"primaryPreferred" o const string$MongoClient::RP_SECONDARY"secondary" o const string$MongoClient::RP_SECONDARY_PREFERRED"secondaryPreferred" o const string$MongoClient::RP_NEAREST"nearest" Properties o public boolean$connected FALSE o public string$status NULL o protected string$server NULL o protected boolean$persistent NULL Methods o public MongoClient::__construct TRUE ([string $server = "mongodb://localhost:27017"], [array $options = )], [array $driver_options]) o public bool MongoClient::close ([boolean|string $connection]) o public bool MongoClient::connect (void ) o public array MongoClient::dropDB (mixed $db) o public MongoDB MongoClient::__get (string $dbname) o publicstatic array MongoClient::getConnections (void ) o public array MongoClient::getHosts (void ) o public array MongoClient::getReadPreference (void ) o public array MongoClient::getWriteConcern (void ) o public bool MongoClient::killCursor (string $server_hash, int|MongoInt64 $id) o public array MongoClient::listDBs (void ) o public MongoCollection MongoClient::selectCollection (string $db, string $collection) o public MongoDB MongoClient::selectDB (string $name) o public bool MongoClient::setReadPreference (string $read_preference, [array $tags]) o public bool MongoClient::setWriteConcern (mixed $w, [int $wtimeout]) o public string MongoClient::__toString (void ) PREDEFINED CONSTANTS
MONGOCLIENT CONSTANTS
o MongoClient::VERSION - PHP driver version. May be suffixed with "dev", "+" or "-" if it is in-between versions. o MongoClient::DEFAULT_HOST - "localhost" - Host to connect to if no host is given. o MongoClient::DEFAULT_PORT - 27017 - Port to connect to if no port is given. o MongoClient::RP_PRIMARY - "primary" -Read preference for the primary replica set member. o MongoClient::RP_PRIMARY_PREFERRED - "primaryPreferred" -Read preference for preferring the primary replica set member. o MongoClient::RP_SECONDARY - "secondary" -Read preference for a secondary replica set member. o MongoClient::RP_SECONDARY_PREFERRED - "secondaryPreferred" -Read preference for preferring a secondary replica set member. o MongoClient::RP_NEAREST - "nearest" -Read preference for the nearest replica set member. FIELDS
o $connected - This property will be set to TRUE if we have a open connection to the database, FALSE otherwise. If the connection is to a replica set, this property will only be TRUE if the driver has a connection to a node matching the current read preference. This property does not take authentication into account. This property is deprecated since version 1.5.0. o $status - This property is no longer used and will be set to NULL In driver versions 1.1.x and earlier, this may be set to a string value (e.g. "recycled", "new") when persistent connections are used. This property is deprecated since version 1.5.0. SEE ALSO
o"Read Preferences" o"Write Concerns" o"Connecting" oMongoDB core docs on connecting PHP Documentation Group MONGOCLIENT(3)
Man Page