downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/class.mongocursor.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/book.mongo.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'class.mongocursor.php',
   
1 => 'MongoCursor',
  ),
 
'up' =>
  array (
   
0 => 'book.mongo.php',
   
1 => 'Mongo',
  ),
 
'prev' =>
  array (
   
0 => 'mongocollection.validate.php',
   
1 => 'MongoCollection::validate',
  ),
 
'next' =>
  array (
   
0 => 'mongocursor.construct.php',
   
1 => 'MongoCursor::__construct',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div>

 <h1 class="title">The MongoCursor class</h1>
 

 <div class="partintro">

 
  <div id="mongocursor.intro" class="section">
   <h2 class="title">Introduction</h2>
   <p class="para">
    Result object for database query.
   </p>
   <p class="para">
    A <b class="classname">MongoCursor</b> has two &quot;life stages&quot;: pre- and post-
    query.  A cursor can be created manually by calling the constructor, but it
    is most often created by calling <a href="mongocollection.find.php" class="function">MongoCollection::find()</a>.
    When a cursor is created, it has not yet contacted the database, so it is in
    its pre-query state.  In this state, the client can further specify what
    they want the query to do, including adding limits, skips, sorts, and more
    advanced options.
   </p>
   <p class="para">
    When the client attempts to get a result (by calling
    <a href="mongocursor.next.php" class="function">MongoCursor::next()</a>, directly or indirectly), the cursor
    moves into the post-query stage.  At this point, the query has been executed
    by the database and cannot be modified anymore.  At this point, the only
    functions available are the <a href="class.iterator.php" class="classname">Iterator</a> functions,
    <a href="mongocursor.hasnext.php" class="function">MongoCursor::hasNext()</a>, and
    <a href="mongocursor.getnext.php" class="function">MongoCursor::getNext()</a>.
   </p>
   <p class="para">
    </p><div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$cursor&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">find</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">limit</span><span style="color: #007700">(</span><span style="color: #0000BB">10</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;database&nbsp;has&nbsp;not&nbsp;yet&nbsp;been&nbsp;queried,&nbsp;so&nbsp;more&nbsp;search&nbsp;options&nbsp;can&nbsp;be&nbsp;added<br /></span><span style="color: #0000BB">$cursor&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$cursor</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">sort</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"a"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$cursor</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getNext</span><span style="color: #007700">());<br /></span><span style="color: #FF8000">//&nbsp;now&nbsp;database&nbsp;has&nbsp;been&nbsp;queried&nbsp;and&nbsp;more&nbsp;options&nbsp;cannot&nbsp;be&nbsp;added<br /><br />//&nbsp;so&nbsp;this&nbsp;will&nbsp;throw&nbsp;an&nbsp;exception:<br /></span><span style="color: #0000BB">$cursor</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">skip</span><span style="color: #007700">(</span><span style="color: #0000BB">4</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>
<p>
   </p>
  </div>
 

  <div id="mongocursor.synopsis" class="section">
   <h2 class="title">Class synopsis</h2>

  
   <div class="classsynopsis">
    <div class="ooclass"><b class="classname">MongoCursor</b></div>

   
    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">implements</span>
      <a href="class.iterator.php" class="classname">Iterator</a>
     </span>
     {</div>
   
   
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Static Fields */</div>
    <div class="fieldsynopsis">
     <span class="modifier">static</span>
     <span class="type">boolean</span>
      <var class="varname">$slaveOkay</var>
     <span class="initializer"> = <b><tt class="constant">FALSE</tt></b></span>
    ;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div>
    <div class="methodsynopsis dc-description">
    <span class="methodname"><a href="mongocursor.construct.php" class="function">__construct</a></span>
    ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$connection</tt></span>
   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$ns</tt></span>
   [, <span class="methodparam"><span class="type">array</span> <tt class="parameter">$query</tt><span class="initializer"> = array()</span></span>
   [, <span class="methodparam"><span class="type">array</span> <tt class="parameter">$fields</tt><span class="initializer"> = array()</span></span>
  ]] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><a href="mongocursor.count.php" class="function">count</a></span>
    ([ <span class="methodparam"><span class="type">boolean</span> <tt class="parameter">$all</tt><span class="initializer"> = <b><tt class="constant">FALSE</tt></b></span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><a href="mongocursor.current.php" class="function">current</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">boolean</span> <span class="methodname"><a href="mongocursor.dead.php" class="function">dead</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">protected</span> <span class="type">void</span> <span class="methodname"><a href="mongocursor.doquery.php" class="function">doQuery</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><a href="mongocursor.explain.php" class="function">explain</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><a href="mongocursor.getnext.php" class="function">getNext</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">boolean</span> <span class="methodname"><a href="mongocursor.hasnext.php" class="function">hasNext</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">MongoCursor</span> <span class="methodname"><a href="mongocursor.hint.php" class="function">hint</a></span>
    ( <span class="methodparam"><span class="type">array</span> <tt class="parameter">$key_pattern</tt></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">MongoCursor</span> <span class="methodname"><a href="mongocursor.immortal.php" class="function">immortal</a></span>
    ([ <span class="methodparam"><span class="type">boolean</span> <tt class="parameter">$liveForever</tt><span class="initializer"> = true</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><a href="mongocursor.key.php" class="function">key</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">MongoCursor</span> <span class="methodname"><a href="mongocursor.limit.php" class="function">limit</a></span>
    ( <span class="methodparam"><span class="type">int</span> <tt class="parameter">$num</tt></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="mongocursor.next.php" class="function">next</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="mongocursor.reset.php" class="function">reset</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="mongocursor.rewind.php" class="function">rewind</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">MongoCursor</span> <span class="methodname"><a href="mongocursor.skip.php" class="function">skip</a></span>
    ( <span class="methodparam"><span class="type">int</span> <tt class="parameter">$num</tt></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">MongoCursor</span> <span class="methodname"><a href="mongocursor.slaveOkay.php" class="function">slaveOkay</a></span>
    ([ <span class="methodparam"><span class="type">boolean</span> <tt class="parameter">$okay</tt><span class="initializer"> = true</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">MongoCursor</span> <span class="methodname"><a href="mongocursor.snapshot.php" class="function">snapshot</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">MongoCursor</span> <span class="methodname"><a href="mongocursor.sort.php" class="function">sort</a></span>
    ( <span class="methodparam"><span class="type">array</span> <tt class="parameter">$fields</tt></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">MongoCursor</span> <span class="methodname"><a href="mongocursor.tailable.php" class="function">tailable</a></span>
    ([ <span class="methodparam"><span class="type">boolean</span> <tt class="parameter">$tail</tt><span class="initializer"> = true</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">boolean</span> <span class="methodname"><a href="mongocursor.valid.php" class="function">valid</a></span>
    ( <span class="methodparam">void</span>
   )</div>

   }</div>
  

  </div>

 </div>

 



 





 





 





 





 





 





 





 





 





 





 





 





 





 





 





 





 





 





 





 





 



<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="mongocursor.construct.php">MongoCursor::__construct</a> — Create a new cursor</li><li><a href="mongocursor.count.php">MongoCursor::count</a> — Counts the number of results for this query</li><li><a href="mongocursor.current.php">MongoCursor::current</a> — Returns the current element</li><li><a href="mongocursor.dead.php">MongoCursor::dead</a> — Checks if there are documents that have not been sent yet from the database for this cursor</li><li><a href="mongocursor.doquery.php">MongoCursor::doQuery</a> — Execute the query.</li><li><a href="mongocursor.explain.php">MongoCursor::explain</a> — Return an explanation of the query, often useful for optimization and debugging</li><li><a href="mongocursor.getnext.php">MongoCursor::getNext</a> — Return the next object to which this cursor points, and advance the cursor</li><li><a href="mongocursor.hasnext.php">MongoCursor::hasNext</a> — Checks if there are any more elements in this cursor</li><li><a href="mongocursor.hint.php">MongoCursor::hint</a> — Gives the database a hint about the query</li><li><a href="mongocursor.immortal.php">MongoCursor::immortal</a> — Sets whether this cursor will timeout</li><li><a href="mongocursor.key.php">MongoCursor::key</a> — Returns the current result's _id</li><li><a href="mongocursor.limit.php">MongoCursor::limit</a> — Limits the number of results returned</li><li><a href="mongocursor.next.php">MongoCursor::next</a> — Advances the cursor to the next result</li><li><a href="mongocursor.reset.php">MongoCursor::reset</a> — Clears the cursor</li><li><a href="mongocursor.rewind.php">MongoCursor::rewind</a> — Returns the cursor to the beginning of the result set</li><li><a href="mongocursor.skip.php">MongoCursor::skip</a> — Skips a number of results</li><li><a href="mongocursor.slaveOkay.php">MongoCursor::slaveOkay</a> — Sets whether this query can be done on a slave</li><li><a href="mongocursor.snapshot.php">MongoCursor::snapshot</a> — Use snapshot mode for the query</li><li><a href="mongocursor.sort.php">MongoCursor::sort</a> — Sorts the results by given fields</li><li><a href="mongocursor.tailable.php">MongoCursor::tailable</a> — Sets whether this cursor will be left open after fetching the last results</li><li><a href="mongocursor.valid.php">MongoCursor::valid</a> — Checks if the cursor is reading a valid result.</li></ul>
</div>
<?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites