Prettify markup and spread id love around

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@328523 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Hannes Magnusson 2012-11-28 04:38:46 +00:00
parent 643260e9ae
commit 73836fe836

View file

@ -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://${username}:${password}@localhost");
$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/myDatabase");
$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", array("replicaSet" => "m
$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 @@ $m = new MongoClient("mongodb://rs1.example.com:27017,rs2.example.com:27017", ar
</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 @@ $m = new MongoClient("mongodb://mongos1.example.com:27017,mongos2.example.com:27
?>
]]>
</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 @@ $m = new MongoClient("mongodb://mongos1.example.com:27017,mongos2.example.com:27
</para>
</section>
<section>
<section xml:id="mongo.connecting.uds">
<title>Domain Socket Support</title>
<para>
@ -154,13 +162,15 @@ $m = new MongoClient("mongodb://mongos1.example.com:27017,mongos2.example.com:27
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 @@ $m = new MongoClient("mongodb:///tmp/mongo-27017.sock");
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 @@ $m = new MongoClient("mongodb://username:password@/tmp/mongo-27017.sock:0/foo");
</section>
</section>
<section>
<section xml:id="mongo.connecting.persistent">
<title>Persistent Connections</title>
<note>
<para>
@ -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:
</para>
<programlisting role="php">
<example xml:id="mongo.connecting.no-persistent-example">
<programlisting role="php">
<![CDATA[
<?php
@ -319,14 +332,16 @@ for ($i=0; $i<1000; $i++) {
?>
]]>
</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 @@ for ($i=0; $i<1000; $i++) {
?>
]]>
</programlisting>
</programlisting>
</example>
<para>
...it takes less than .02 seconds to execute, as it only makes one database