php-doc-en/reference/mongo/mongodb/getreadpreference.xml

113 lines
2.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="mongodb.getreadpreference" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>MongoDB::getReadPreference</refname>
<refpurpose>Get the read preference for this database</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>array</type><methodname>MongoDB::getReadPreference</methodname>
<void />
</methodsynopsis>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
This function returns an array describing the read preference. The array
contains the values <literal>type</literal> for the numeric read preference
mode, <literal>type_string</literal> for the name of the read preference
mode, and <literal>tagsets</literal> containing a list of all tag set
criteria. If no tag sets were specified, <literal>tagsets</literal> will not
be present in the array.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><methodname>MongoDB::getReadPreference</methodname> return value example</title>
<programlisting role="php">
<![CDATA[
<?php
$m = new Mongo();
$db = $m->test;
$db->setReadPreference(Mongo::RP_SECONDARY, array(
array('dc' => 'east', 'use' => 'reporting'),
array('dc' => 'west'),
array(),
));
var_dump($db->getReadPreference());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(3) {
["type"]=>
int(2)
["type_string"]=>
string(9) "secondary"
["tagsets"]=>
array(3) {
[0]=>
array(2) {
[0]=>
string(7) "dc:east"
[1]=>
string(13) "use:reporting"
}
[1]=>
array(1) {
[0]=>
string(7) "dc:west"
}
[2]=>
array(0) {
}
}
}
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member>The <link linkend="mongo.readpreferences">read preferences</link> documentation.</member>
</simplelist>
</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
-->