Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 9984

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!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>Executes the command and resets the cursor to the start of the result set</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongocommandcursor.next.html">MongoCommandCursor::next</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongocommandcursor.setreadpreference.html">MongoCommandCursor::setReadPreference</a></div>
 <div class="up"><a href="class.mongocommandcursor.html">MongoCommandCursor</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongocommandcursor.rewind" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoCommandCursor::rewind</h1>
  <p class="verinfo">(PECL mongo &gt;=1.5.0)</p><p class="refpurpose"><span class="refname">MongoCommandCursor::rewind</span> &mdash; <span class="dc-title">Executes the command and resets the cursor to the start of the result set</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongocommandcursor.rewind-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>MongoCommandCursor::rewind</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   If the cursor has already started iteration, the command will be re-executed.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongocommandcursor.rewind-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">This function has no parameters.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongocommandcursor.rewind-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The raw server result document.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongocommandcursor.rewind-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   Throws <a href="class.mongoconnectionexception.html" class="classname">MongoConnectionException</a> if it cannot reach the
   database and <a href="class.mongocursortimeoutexception.html" class="classname">MongoCursorTimeoutException</a> if the
   timeout is exceeded.
  </p>
  <p class="para">
   Throws <a href="class.mongocursorexception.html" class="classname">MongoCursorException</a> if the cursor was created
   with <span class="function"><a href="mongocommandcursor.createfromdocument.html" class="function">MongoCommandCursor::createFromDocument()</a></span> and has
   already started iteration. Such cursors cannot be iterated multiple times, as
   they lack the original command necessary for re-execution.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongocommandcursor.rewind-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-1638">
   <p><strong>Example #1 <span class="function"><strong>MongoCommandCursor::rewind()</strong></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$rawResult&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$commandCursor</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">rewind</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;Command&nbsp;cursor&nbsp;is&nbsp;now&nbsp;reset&nbsp;to&nbsp;the&nbsp;start&nbsp;of&nbsp;the&nbsp;result&nbsp;set<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$rawResult</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above example will output
something similar to:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
array(2) {
  [&quot;cursor&quot;]=&gt;
  array(3) {
    [&quot;id&quot;]=&gt;
    object(MongoInt64)#5 (1) {
      [&quot;value&quot;]=&gt;
      string(12) &quot;310050110216&quot;
    }
    [&quot;ns&quot;]=&gt;
    string(9) &quot;demo.test&quot;
    [&quot;firstBatch&quot;]=&gt;
    array(1) {
      [0]=&gt;
      array(2) {
        [&quot;_id&quot;]=&gt;
        object(MongoId)#6 (1) {
          [&quot;$id&quot;]=&gt;
          string(24) &quot;52f5691544670a8077b0dc51&quot;
        }
        [&quot;value&quot;]=&gt;
        string(2) &quot;42&quot;
      }
    }
  }
  [&quot;ok&quot;]=&gt;
  float(1)
}
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongocommandcursor.rewind-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"><span class="methodname"><a href="iterator.rewind.html" class="methodname" rel="rdfs-seeAlso">Iterator::rewind()</a> - Rewind the Iterator to the first element</span></li>
  </ul>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongocommandcursor.next.html">MongoCommandCursor::next</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongocommandcursor.setreadpreference.html">MongoCommandCursor::setReadPreference</a></div>
 <div class="up"><a href="class.mongocommandcursor.html">MongoCommandCursor</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>