<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Set the read preference for this query</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongocursorinterface.info.html">MongoCursorInterface::info</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongocursorinterface.timeout.html">MongoCursorInterface::timeout</a></div> <div class="up"><a href="class.mongocursorinterface.html">MongoCursorInterface</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mongocursorinterface.setreadpreference" class="refentry"> <div class="refnamediv"> <h1 class="refname">MongoCursorInterface::setReadPreference</h1> <p class="verinfo">(PECL mongo >=1.6.0)</p><p class="refpurpose"><span class="refname">MongoCursorInterface::setReadPreference</span> — <span class="dc-title">Set the read preference for this query</span></p> </div> <div class="refsect1 description" id="refsect1-mongocursorinterface.setreadpreference-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">abstract</span> <span class="modifier">public</span> <span class="type"><a href="class.mongocursorinterface.html" class="type MongoCursorInterface">MongoCursorInterface</a></span> <span class="methodname"><strong>MongoCursorInterface::setReadPreference</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$read_preference</code></span> [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$tags</code></span> ] )</div> </div> <div class="refsect1 parameters" id="refsect1-mongocursorinterface.setreadpreference-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <code class="parameter">read_preference</code></dt> <dd> <p class="para">The read preference mode: <strong><code>MongoClient::RP_PRIMARY</code></strong>, <strong><code>MongoClient::RP_PRIMARY_PREFERRED</code></strong>, <strong><code>MongoClient::RP_SECONDARY</code></strong>, <strong><code>MongoClient::RP_SECONDARY_PREFERRED</code></strong>, or <strong><code>MongoClient::RP_NEAREST</code></strong>.</p></dd> <dt> <code class="parameter">tags</code></dt> <dd> <p class="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.</p></dd> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-mongocursorinterface.setreadpreference-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns this cursor. </p> </div> <div class="refsect1 errors" id="refsect1-mongocursorinterface.setreadpreference-errors"> <h3 class="title">Errors/Exceptions</h3> <p class="para">Emits <strong><code>E_WARNING</code></strong> if either parameter is invalid, or if one or more tag sets are provided with the <strong><code>MongoClient::RP_PRIMARY</code></strong> read preference mode.</p> </div> <div class="refsect1 seealso" id="refsect1-mongocursorinterface.setreadpreference-seealso"> <h3 class="title">See Also</h3> <ul class="simplelist"> <li class="member">The <a href="mongo.readpreferences.html" class="link">read preferences</a> documentation.</li> <li class="member"><span class="function"><a href="mongocursorinterface.getreadpreference.html" class="function" rel="rdfs-seeAlso">MongoCursorInterface::getReadPreference()</a> - Get the read preference for this query</span></li> </ul> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongocursorinterface.info.html">MongoCursorInterface::info</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongocursorinterface.timeout.html">MongoCursorInterface::timeout</a></div> <div class="up"><a href="class.mongocursorinterface.html">MongoCursorInterface</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>