Clarify handling of database name URI component

https://jira.mongodb.org/browse/PHPC-1384


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@350007 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Jeremy Mikola 2020-06-03 19:27:03 +00:00
parent b166d394e6
commit f9e44aad38

View file

@ -46,12 +46,12 @@
A <link xlink:href="&url.mongodb.docs;reference/connection-string/">mongodb://</link> connection URI:
<programlisting role="txt">
<![CDATA[
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[defaultAuthDb][?options]]
]]>
</programlisting>
</para>
<para>
For details on supported options, see
For details on supported URI options, see
<link xlink:href="&url.mongodb.docs;reference/connection-string/#connections-connection-options">Connection String Options</link>
in the MongoDB manual.
<link xlink:href="&url.mongodb.docs;reference/connection-string/#connection-pool-options">Connection pool options</link>
@ -68,6 +68,15 @@ mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][
The <function>rawurlencode</function> function may be used to encode
constituent parts of the URI.
</para>
<para>
The <literal>defaultAuthDb</literal> component may be used to specify the
database name associated with the user's credentials; however the
<literal>authSource</literal> URI option will take priority if specified.
If neither <literal>defaultAuthDb</literal> nor
<literal>authSource</literal> are specified, the <literal>admin</literal>
database will be used by default. The <literal>defaultAuthDb</literal>
component has no effect in the absence of user credentials.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="mongodb-driver-manager.construct-urioptions">
@ -145,7 +154,8 @@ mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][
<entry>
<para>
The database name associated with the user's credentials. Defaults
to the database component of the connection URI.
to the database component of the connection URI, or the
<literal>admin</literal> database if both are unspecified.
</para>
<para>
For authentication mechanisms that delegate credential storage to
@ -1071,7 +1081,7 @@ $manager = new MongoDB\Driver\Manager("mongodb://mongos1.example.com,mongos2.exa
<![CDATA[
<?php
$manager = new MongoDB\Driver\Manager("mongodb://myusername:mypassword@example.com/mydatabase");
$manager = new MongoDB\Driver\Manager("mongodb://myusername:mypassword@example.com/?authSource=databaseName");
?>
]]>
@ -1090,7 +1100,7 @@ $manager = new MongoDB\Driver\Manager("mongodb://myusername:mypassword@example.c
<![CDATA[
<?php
$manager = new MongoDB\Driver\Manager("mongodb://myusername:myp%40ss%3Aw%25rd@example.com/mydatabase");
$manager = new MongoDB\Driver\Manager("mongodb://myusername:myp%40ss%3Aw%25rd@example.com/?authSource=databaseName");
?>
]]>