mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-28 23:08:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@333246 c90b9560-bf6c-de11-be94-00142212c4b1
139 lines
4.4 KiB
XML
139 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<!-- $Revision: 331219 $ -->
|
|
<phpdoc:classref xml:id="class.mongocommandcursor" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
|
|
<title>The MongoCommandCursor class</title>
|
|
<titleabbrev>MongoCommandCursor</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
<!-- {{{ MongocommandCursor intro -->
|
|
<section xml:id="mongocommandcursor.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
A command cursor is used to iterate through the results of a database
|
|
command. A command cursor is similar to a normal
|
|
<classname>MongoCursor</classname> except that you use it for iterating
|
|
through the result of a server command instead of a the result of a query.
|
|
</para>
|
|
<para>
|
|
You don't generally create cursors using the
|
|
<classname>MongoCommandCursor</classname> constructor, you get a new cursor by
|
|
calling <function>MongoCollection::commandCursor</function>.
|
|
</para>
|
|
<para>
|
|
Using a command cursor instead of
|
|
<methodname>MongoDB::command</methodname> means that you can iterate over
|
|
a much larger resultset as the return of
|
|
<methodname>MongoDB::command</methodname> is limited to the maximum
|
|
document size (currently 16MB).
|
|
</para>
|
|
<para>
|
|
Note that the cursor does not "contain" the database command results, it
|
|
just manages them. Thus, if you print a cursor (with, say,
|
|
<function>var_dump</function> or <function>print_r</function>), you'll
|
|
just get the cursor object, not your documents.
|
|
</para>
|
|
</section>
|
|
|
|
<section>
|
|
<title>Cursor Stages</title>
|
|
<para>
|
|
A <classname>MongoCommandCursor</classname> has two "life stages": pre-
|
|
and post- query. 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 configuring the
|
|
batch size.
|
|
</para>
|
|
<para>
|
|
When the client attempts to get a result (by calling
|
|
<function>MongoCommandCursor::next</function>, directly or indirectly),
|
|
the cursor moves into the post-command stage. At this point, the command
|
|
has been executed by the database and only its batch size can be
|
|
configured.
|
|
</para>
|
|
<para>
|
|
<example xml:id="mongocommandcursor.stages.adding-options">
|
|
<title>Adding options to <classname>MongoCommandCursor</classname></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$cursor = new MongoCommandCursor(...);
|
|
|
|
// database has not yet been queried, so more options can be added
|
|
$cursor = $cursor->batchSize( 4 );
|
|
|
|
var_dump($cursor->getNext());
|
|
// now database has been queried and more options cannot be added
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</section>
|
|
<!-- }}} -->
|
|
|
|
<section xml:id="mongocommandcursor.synopsis">
|
|
&reftitle.classsynopsis;
|
|
|
|
<!-- {{{ Synopsis -->
|
|
<classsynopsis>
|
|
<ooclass><classname>MongoCommandCursor</classname></ooclass>
|
|
|
|
<!-- {{{ Class synopsis -->
|
|
<classsynopsisinfo>
|
|
<ooclass>
|
|
<classname>MongoCommandCursor</classname>
|
|
</ooclass>
|
|
<oointerface>
|
|
<interfacename>Iterator</interfacename>
|
|
</oointerface>
|
|
<oointerface>
|
|
<interfacename>MongoCursorInterface</interfacename>
|
|
</oointerface>
|
|
</classsynopsisinfo>
|
|
<!-- }}} -->
|
|
|
|
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongocommandcursor')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
|
|
</classsynopsis>
|
|
<!-- }}} -->
|
|
|
|
</section>
|
|
|
|
<section role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><methodname>MongoDb::command</methodname></member>
|
|
<member><methodname>MongoCollection::commandCursor</methodname></member>
|
|
</simplelist>
|
|
</section>
|
|
|
|
</partintro>
|
|
|
|
&reference.mongo.entities.mongocommandcursor;
|
|
|
|
</phpdoc:classref>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|