diff --git a/reference/mongo/connecting.xml b/reference/mongo/connecting.xml index abc6eabbb9..b29672cea7 100644 --- a/reference/mongo/connecting.xml +++ b/reference/mongo/connecting.xml @@ -12,7 +12,7 @@ cases. -
+
Authentication If MongoDB is started with the --auth or @@ -22,7 +22,8 @@ "username" and "password" options for MongoClient::__construct. - + + $username, "password" => $password)); ?> ]]> - + + By default, the driver will authenticate against the admin database. You may authenticate against a different database by specifying it in either the connection URI or the "db" option for MongoClient::__construct. - + + "myDatabase")); ?> ]]> - + + If your connection is dropped, the driver will automatically attempt to reconnect and reauthenticate you.
-
+
Replica Sets To connect to a replica set, specify one or more members of the set and use the "replicaSet" option. Multiple servers may be delimited by a comma. - + + "m $m = new MongoClient("mongodb://rs1.example.com:27017,rs2.example.com:27017", array("replicaSet" => "myReplSetName")); ?> ]]> - + + Version 1.0.9+ of the driver is required to connect to a replica set. Earlier versions of the driver will not auto-detect the primary or reconnect @@ -109,14 +115,15 @@ $m = new MongoClient("mongodb://rs1.example.com:27017,rs2.example.com:27017", ar
-
+
Sharding To connect to a shard cluster, specify the address of one or more mongos instances in the connection string. Multiple servers may be delimited by a comma. - + > + ]]> - + + Regardless of whether each shard is a stand-alone mongod server or a full replica set, the driver's connection process is the same. @@ -140,7 +148,7 @@ $m = new MongoClient("mongodb://mongos1.example.com:27017,mongos2.example.com:27
-
+
Domain Socket Support @@ -154,13 +162,15 @@ $m = new MongoClient("mongodb://mongos1.example.com:27017,mongos2.example.com:27 string: - + + ]]> - + + If you would like to authenticate against a database (as described above) @@ -169,17 +179,19 @@ $m = new MongoClient("mongodb:///tmp/mongo-27017.sock"); Alternatively, you can use the constructor options. - + + ]]> - + +
-
+
Connection Pooling (version 1.2.0-1.2.12 *only*) Creating connections is one of the most heavyweight things that the driver @@ -287,7 +299,7 @@ $m = new MongoClient("mongodb://username:password@/tmp/mongo-27017.sock:0/foo");
-
+
Persistent Connections @@ -309,7 +321,8 @@ $m = new MongoClient("mongodb://username:password@/tmp/mongo-27017.sock:0/foo"); For example, this simple program connects to the database 1000 times: - + + ]]> - + + It takes approximately 18 seconds to execute. If we change it to use a persistent connection: - + + ]]> - + + ...it takes less than .02 seconds to execute, as it only makes one database