<!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>Sets a client-side timeout 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.setreadpreference.html">MongoCursorInterface::setReadPreference</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.mongocommandcursor.html">MongoCommandCursor</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.timeout" class="refentry"> <div class="refnamediv"> <h1 class="refname">MongoCursorInterface::timeout</h1> <p class="verinfo">(PECL mongo >=1.5.0)</p><p class="refpurpose"><span class="refname">MongoCursorInterface::timeout</span> — <span class="dc-title">Sets a client-side timeout for this query</span></p> </div> <div class="refsect1 description" id="refsect1-mongocursorinterface.timeout-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::timeout</strong></span> ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$ms</code></span> )</div> <p class="para rdfs-comment"> A timeout can be set at any time and will affect subsequent data retrieval associated with this cursor, including fetching more results from the database. </p> </div> <div class="refsect1 parameters" id="refsect1-mongocursorinterface.timeout-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <code class="parameter">ms</code> </dt> <dd> <p class="para"> The number of milliseconds for the cursor to wait for a response. Use <em>-1</em> to wait forever. By default, the cursor will wait <var class="varname"><var class="varname">30000</var></var> milliseconds (30 seconds). </p> </dd> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-mongocursorinterface.timeout-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns this cursor. </p> </div> <div class="refsect1 errors" id="refsect1-mongocursorinterface.timeout-errors"> <h3 class="title">Errors/Exceptions</h3> <p class="para"> Causes methods that fetch results to throw a <a href="class.mongocursortimeoutexception.html" class="classname">MongoCursorTimeoutException</a> if the data fetch takes longer than the specified number of milliseconds. </p> </div> <div class="refsect1 seealso" id="refsect1-mongocursorinterface.timeout-seealso"> <h3 class="title">See Also</h3> <ul class="simplelist"> <li class="member">The <em>socketTimeoutMS</em> option for <span class="function"><a href="mongoclient.construct.html" class="function">MongoClient::__construct()</a></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.setreadpreference.html">MongoCursorInterface::setReadPreference</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.mongocommandcursor.html">MongoCommandCursor</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>