<!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>Kills a specific cursor on the server</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongoclient.getreadpreference.html">MongoClient::getReadPreference</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongoclient.listdbs.html">MongoClient::listDBs</a></div> <div class="up"><a href="class.mongoclient.html">MongoClient</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mongoclient.killcursor" class="refentry"> <div class="refnamediv"> <h1 class="refname">MongoClient::killCursor</h1> <p class="verinfo">(No version information available, might only be in SVN)</p><p class="refpurpose"><span class="refname">MongoClient::killCursor</span> — <span class="dc-title">Kills a specific cursor on the server</span></p> </div> <div class="refsect1 description" id="refsect1-mongoclient.killcursor-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>MongoClient::killCursor</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$server_hash</code></span> , <span class="methodparam"><span class="type"><span class="type int|MongoInt64">int|MongoInt64</span></span> <code class="parameter">$id</code></span> )</div> <p class="para rdfs-comment"> In certain situations it might be needed to kill a cursor on the server. Usually cursors time out after 10 minutes of inactivity, but it is possible to create an immortal cursor with <span class="methodname"><a href="mongocursor.immortal.html" class="methodname">MongoCursor::immortal()</a></span> that never times out. In order to be able to kill such an immortal cursor, you can call this method with the information supplied by <span class="methodname"><a href="mongocursor.info.html" class="methodname">MongoCursor::info()</a></span>. </p> </div> <div class="refsect1 parameters" id="refsect1-mongoclient.killcursor-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"> <em><code class="parameter">server_hash</code></em> </span> <dd> <p class="para"> The server hash that has the cursor. This can be obtained through <span class="methodname"><a href="mongocursor.info.html" class="methodname">MongoCursor::info()</a></span>. </p> </dd> </dt> <dt> <span class="term"> <em><code class="parameter">id</code></em> </span> <dd> <p class="para"> The ID of the cursor to kill. You can either supply an <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> containing the 64 bit cursor ID, or an object of the <a href="class.mongoint64.html" class="classname">MongoInt64</a> class. The latter is necessary on 32 bit platforms (and Windows). </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-mongoclient.killcursor-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> if the method attempted to kill a cursor, and <strong><code>FALSE</code></strong> if there was something wrong with the arguments (such as a wrong <em><code class="parameter">server_hash</code></em>). The return status does <em class="emphasis">not reflect</em> where the cursor was actually killed as the server does not provide that information. </p> </div> <div class="refsect1 errors" id="refsect1-mongoclient.killcursor-errors"> <h3 class="title">Errors/Exceptions</h3> <p class="para"> This method displays a warning if the supplied <em><code class="parameter">server_hash</code></em> does not match up with an existing connection. No attempt to kill a cursor is attempted in that case either. </p> </div> <div class="refsect1 examples" id="mongo.mongoclient.killcursor.examples"> <h3 class="title">Examples</h3> <div class="example" id="example-1405"> <p><strong>Example #1 <span class="function"><strong>MongoClient::killCursor()</strong></span> example</strong></p> <div class="example-contents"><p> This example shows how to connect, do a query, obtain the cursor information and then kill the cursor. </p></div> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$m </span><span style="color: #007700">= new </span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">$m</span><span style="color: #007700">-></span><span style="color: #0000BB">testdb</span><span style="color: #007700">-></span><span style="color: #0000BB">collection</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$cursor </span><span style="color: #007700">= </span><span style="color: #0000BB">$c</span><span style="color: #007700">-></span><span style="color: #0000BB">find</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">$cursor</span><span style="color: #007700">-></span><span style="color: #0000BB">next</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// Now the cursor is valid, so we can get the hash and ID out:<br /></span><span style="color: #0000BB">$info </span><span style="color: #007700">= </span><span style="color: #0000BB">$cursor</span><span style="color: #007700">-></span><span style="color: #0000BB">info</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// Kill the cursor<br /></span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">::</span><span style="color: #0000BB">killCursor</span><span style="color: #007700">( </span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">'server'</span><span style="color: #007700">], </span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">'id'</span><span style="color: #007700">] );<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongoclient.getreadpreference.html">MongoClient::getReadPreference</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongoclient.listdbs.html">MongoClient::listDBs</a></div> <div class="up"><a href="class.mongoclient.html">MongoClient</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>