svn: /phpdoc/en/trunk/reference/mongo/ connecting.xml

From: Date: Wed, 28 Nov 2012 04:38:46 +0000
Subject: svn: /phpdoc/en/trunk/reference/mongo/ connecting.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-10784@lists.php.net to get a copy of this message
bjori Wed, 28 Nov 2012 04:38:46 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=328523 Log: Prettify markup and spread id love around Changed paths: U phpdoc/en/trunk/reference/mongo/connecting.xml Modified: phpdoc/en/trunk/reference/mongo/connecting.xml =================================================================== --- phpdoc/en/trunk/reference/mongo/connecting.xml 2012-11-28 04:37:32 UTC (rev 328522) +++ phpdoc/en/trunk/reference/mongo/connecting.xml 2012-11-28 04:38:46 UTC (rev 328523) @@ -12,7 +12,7 @@ cases. </para> - <section> + <section xml:id="mongo.connecting.auth"> <title>Authentication</title> <para> If MongoDB is started with the <literal>--auth</literal> or @@ -22,7 +22,8 @@ <literal>"username"</literal> and <literal>"password"</literal> options for <function>MongoClient::__construct</function>. </para> - <programlisting role="php"> + <example xml:id="mongo.connecting.auth-example"> + <programlisting role="php"> <![CDATA[ <?php // Specifying the username and password in the connection URI (preferred) @@ -32,14 +33,16 @@ $m = new MongoClient("mongodb://localhost", array("username" => $username, "password" => $password)); ?> ]]> - </programlisting> + </programlisting> + </example> <para> By default, the driver will authenticate against the <literal>admin</literal> database. You may authenticate against a different database by specifying it in either the connection URI or the <literal>"db"</literal> option for <function>MongoClient::__construct</function>. </para> - <programlisting role="php"> + <example xml:id="mongo.connecting.auth-db-example"> + <programlisting role="php"> <![CDATA[ <?php // Specifying the authentication database in the connection URI (preferred) @@ -49,21 +52,23 @@ $m = new MongoClient("mongodb://${username}:${password}@localhost", array("db" => "myDatabase")); ?> ]]> - </programlisting> + </programlisting> + </example> <para> If your connection is dropped, the driver will automatically attempt to reconnect and reauthenticate you. </para> </section> - <section> + <section xml:id="mongo.connecting.rs"> <title>Replica Sets</title> <para> To connect to a replica set, specify one or more members of the set and use the <literal>"replicaSet"</literal> option. Multiple servers may be delimited by a comma. </para> - <programlisting role="php"> + <example xml:id="mongo.connecting.rs-example"> + <programlisting role="php"> <![CDATA[ <?php // Using multiple servers as the seed list (prefered) @@ -76,7 +81,8 @@ $m = new MongoClient("mongodb://rs1.example.com:27017,rs2.example.com:27017", array("replicaSet" => "myReplSetName")); ?> ]]> - </programlisting> + </programlisting> + </example> <para> 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 @@ </para> </section> - <section> + <section xml:id="mongo.connecting.mongos"> <title>Sharding</title> <para> To connect to a shard cluster, specify the address of one or more <literal>mongos</literal> instances in the connection string. Multiple servers may be delimited by a comma. </para> - <programlisting role="php"> + <example xml:id="mongo.connecting.mongos-example">> + <programlisting role="php"> <![CDATA[ <?php @@ -128,7 +135,8 @@ ?> ]]> - </programlisting> + </programlisting> + </example> <para> Regardless of whether each shard is a stand-alone <literal>mongod</literal> server or a full replica set, the driver's connection process is the same. @@ -140,7 +148,7 @@ </para> </section> - <section> + <section xml:id="mongo.connecting.uds"> <title>Domain Socket Support</title> <para> @@ -154,13 +162,15 @@ string: </para> - <programlisting role="php"> + <example xml:id="mongo.connecting.uds-example"> + <programlisting role="php"> <![CDATA[ <?php $m = new MongoClient("mongodb:///tmp/mongo-27017.sock"); ?> ]]> - </programlisting> + </programlisting> + </example> <para> If you would like to authenticate against a database (as described above) @@ -169,17 +179,19 @@ Alternatively, you can use the constructor options. </para> - <programlisting role="php"> + <example xml:id="mongo.connecting.uds-auth-example"> + <programlisting role="php"> <![CDATA[ <?php $m = new MongoClient("mongodb://username:password@/tmp/mongo-27017.sock:0/foo"); ?> ]]> - </programlisting> + </programlisting> + </example> </section> - <section> + <section xml:id="mongo.connecting.pools"> <title>Connection Pooling (version 1.2.0-1.2.12 *only*)</title> <para> Creating connections is one of the most heavyweight things that the driver @@ -287,7 +299,7 @@ </section> </section> - <section> + <section xml:id="mongo.connecting.persistent"> <title>Persistent Connections</title> <note> <para> @@ -309,7 +321,8 @@ For example, this simple program connects to the database 1000 times: </para> - <programlisting role="php"> + <example xml:id="mongo.connecting.no-persistent-example"> + <programlisting role="php"> <![CDATA[ <?php @@ -319,14 +332,16 @@ ?> ]]> - </programlisting> + </programlisting> + </example> <para> It takes approximately 18 seconds to execute. If we change it to use a persistent connection: </para> - <programlisting role="php"> + <example xml:id="mongo.connecting.persistent-example"> + <programlisting role="php"> <![CDATA[ <?php @@ -336,7 +351,8 @@ ?> ]]> - </programlisting> + </programlisting> + </example> <para> ...it takes less than .02 seconds to execute, as it only makes one database

« previous php.doc.cvs (#10784) next »