MongoClient::setReadPreference

(PECL mongo >=1.3.0) Set the read preference for this connection public bool MongoClient::setReadPreference ( string $read_preference [, array $tags ] ) Parameters: read_preference The read preference mode: MongoClient::RP_PRIMARY, MongoClient::RP_PRIMARY_PREFERRED, MongoClient::RP_SECONDARY, MongoClient::RP_SECONDARY_PREFERRED, or MongoClient::RP_NEAREST.

MongoClient::selectDB

(PECL mongo >=1.3.0) Gets a database public MongoDB MongoClient::selectDB ( string $name ) Parameters: name The database name. Returns: Returns a new database object. Exception: Throws Exception if the database name is invalid.

MongoClient::selectCollection

(PECL mongo >=1.3.0) Gets a database collection public MongoCollection MongoClient::selectCollection ( string $db, string $collection ) Parameters: db The database name. collection The collection name. Returns: Returns a new collection object. Exception: Throws Exception if th

MongoClient::listDBs

(PECL mongo >=1.3.0) Lists all of the databases available. public array MongoClient::listDBs ( void ) Returns: Returns an associative array containing three fields. The first field is databases, which in turn contains an array. Each element of the array is an associative array corresponding to a database, giving th database's name, size, and if it's empty. The other two fields are totalSize (in b

MongoClient::killCursor

(PECL mongo >=1.5.0) Kills a specific cursor on the server public bool MongoClient::killCursor ( string $server_hash, int|MongoInt64 $id ) In certain situations it might be needed to kill a cursor on the server. Usually cursors time out after 10 minutes of inactivity, but it is possible to create an immortal cursor with MongoCursor::immortal() that never times out. In order to be able to kill such an immortal cursor, you

MongoClient::getWriteConcern

(PECL mongo >=1.5.0) Get the write concern for this connection public array MongoClient::getWriteConcern ( void ) Returns: This function returns an array describing the write concern. The array contains the values w for an integer acknowledgement level or string mode, and wtimeout denoting the maximum number of milliseconds to wait for the server to satisfy the write concern.

MongoClient::getReadPreference

(PECL mongo >=1.3.0) Get the read preference for this connection public array MongoClient::getReadPreference ( void ) Returns: This function returns an array describing the read preference. The array contains the values type for the string read preference mode (corresponding to the MongoClient constants), and tagsets containing a list of all tag set criteria. If no tag sets were specified, tagsets

MongoClient::getHosts

(PECL mongo >=1.3.0) Updates status for all associated hosts public array MongoClient::getHosts ( void ) This method is only useful with a connection to a replica set. It returns the status of all of the hosts in the set. Without a replica set, it will just return an array with one element containing the host that you are connected to. See the query section of this manual for information on distributing reads to seconda

MongoClient::getConnections

(PECL mongo >=1.3.0) Return info about all open connections public static array MongoClient::getConnections ( void ) Returns an array of all open connections, and information about each of the servers Returns: An array of open connections. Examples: MongoClient::getConnections() example <?php $m = new MongoClient; v

MongoClient::__get

(PECL mongo >=1.3.0) Gets a database public MongoDB MongoClient::__get ( string $dbname ) This is the cleanest way of getting a database. If the database name has any special characters, MongoClient::selectDB() will need to be used; however, this should be sufficient for most cases. <?php $mongo = new MongoClient(); // the following two lines are equivalent $db = $mongo->selectDB("foo"); $db = $mongo->foo;