mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-25 05:18:56 +00:00
101 lines
2.8 KiB
XML
101 lines
2.8 KiB
XML
![]() |
<?xml version="1.0" encoding="utf-8"?>
|
||
|
<!-- $Revision$ -->
|
||
|
|
||
|
<refentry xml:id="mongodb.setreadpreference" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||
|
<refnamediv>
|
||
|
<refname>MongoDB::setReadPreference</refname>
|
||
|
<refpurpose>Set the read preference for this database</refpurpose>
|
||
|
</refnamediv>
|
||
|
|
||
|
<refsect1 role="description">
|
||
|
&reftitle.description;
|
||
|
<methodsynopsis>
|
||
|
<modifier>public</modifier> <type>bool</type><methodname>MongoDB::setReadPreference</methodname>
|
||
|
<methodparam><type>string</type><parameter>read_preference</parameter></methodparam>
|
||
|
<methodparam choice="opt"><type>array</type><parameter>tags</parameter></methodparam>
|
||
|
</methodsynopsis>
|
||
|
<para>
|
||
|
See the <link linkend="mongo.readpreferences">read preferences</link> section
|
||
|
of this manual for further information.
|
||
|
</para>
|
||
|
</refsect1>
|
||
|
|
||
|
<refsect1 role="parameters">
|
||
|
&reftitle.parameters;
|
||
|
<variablelist>
|
||
|
<varlistentry>
|
||
|
<term><parameter>read_preference</parameter></term>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
The read preference mode: <constant>Mongo::RP_PRIMARY</constant>,
|
||
|
<constant>Mongo::RP_PRIMARY_PREFERRED</constant>,
|
||
|
<constant>Mongo::RP_SECONDARY</constant>,
|
||
|
<constant>Mongo::RP_SECONDARY_PREFERRED</constant>, or
|
||
|
<constant>Mongo::RP_NEAREST</constant>.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
</varlistentry>
|
||
|
<varlistentry>
|
||
|
<term><parameter>tags</parameter></term>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
An array of zero or more tag sets, where each tag set is itself an array
|
||
|
of criteria used to match tags on replica set members.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
</varlistentry>
|
||
|
</variablelist>
|
||
|
</refsect1>
|
||
|
|
||
|
<refsect1 role="returnvalues">
|
||
|
&reftitle.returnvalues;
|
||
|
<para>
|
||
|
Returns &true; on success, or &false; otherwise.
|
||
|
</para>
|
||
|
</refsect1>
|
||
|
|
||
|
<refsect1 role="examples">
|
||
|
&reftitle.examples;
|
||
|
<example>
|
||
|
<title><function>MongoDB::setReadPreference</function> tag set array syntax example</title>
|
||
|
<programlisting role="php">
|
||
|
<![CDATA[
|
||
|
<?php
|
||
|
|
||
|
$m = new Mongo();
|
||
|
$db = $m->test;
|
||
|
|
||
|
// Prefer the nearest server in the "east" data center also used for reporting,
|
||
|
// but fall back to a server in the "west" data center
|
||
|
$db->setReadPreference(Mongo::RP_NEAREST, array(
|
||
|
array('dc' => 'east', 'use' => 'reporting'),
|
||
|
array('dc' => 'west'),
|
||
|
));
|
||
|
]]>
|
||
|
</programlisting>
|
||
|
</example>
|
||
|
</refsect1>
|
||
|
|
||
|
</refentry>
|
||
|
|
||
|
<!-- Keep this comment at the end of the file
|
||
|
Local variables:
|
||
|
mode: sgml
|
||
|
sgml-omittag:t
|
||
|
sgml-shorttag:t
|
||
|
sgml-minimize-attributes:nil
|
||
|
sgml-always-quote-attributes:t
|
||
|
sgml-indent-step:1
|
||
|
sgml-indent-data:t
|
||
|
indent-tabs-mode:nil
|
||
|
sgml-parent-document:nil
|
||
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
||
|
sgml-exposed-tags:nil
|
||
|
sgml-local-catalogs:nil
|
||
|
sgml-local-ecat-files:nil
|
||
|
End:
|
||
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||
|
vim: et tw=78 syn=sgml
|
||
|
vi: ts=1 sw=1
|
||
|
-->
|