php-doc-en/reference/mongo/mongocursor/batchsize.xml
Kristina Chodorow 666f9c872a fixed batchSize doc
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@305656 c90b9560-bf6c-de11-be94-00142212c4b1
2010-11-22 15:31:15 +00:00

110 lines
2.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="mongocursor.batchsize" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>MongoCursor::batchSize</refname>
<refpurpose>Sets the number of results returned per result set</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>MongoCursor</type><methodname>MongoCursor::batchSize</methodname>
<methodparam><type>int</type><parameter>num</parameter></methodparam>
</methodsynopsis>
<para>
This cannot override MongoDB's limit on the amount of data it will return to
the client (i.e., if you set batch size to 1,000,000,000, MongoDB will still
only return 4-16MB of results).
</para>
<para>
To ensure consistent behavior, the rules of batchSize and limit behavior a
little complex but work "as expected". The rules are: hard limits override
soft limits with preference given to <function>MongoCursor::limit</function>
over <function>MongoCursor::batchSize</function>. After that, whichever is
set and lower than the other will take precedence. Some examples:
</para>
<programlisting role="php">
<![CDATA[
<?php
// one batch, at most 20 items
$cursor->limit(-20)->batchSize(10);
// one batch, at most 10 items
$cursor->limit(20)->batchSize(-10);
// first batch: at most 10 items
$cursor->limit(10);
// first batch: at most 10 items
$cursor->limit(10)->batchSize(20);
// first batch: at most 10 items
$cursor->limit(20)->batchSize(10);
$cursor->limit(30)->batchSize(7)
// if we iterate through 28 items, the next call to getNext() will contact the
// database and request a batch of 2 documents
?>
]]>
</programlisting>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term>
<parameter>num</parameter>
</term>
<listitem>
<para>
The number of results to return in the next batch.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns this cursor.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Throws <classname>MongoCursorException</classname> if this cursor has
started iterating. This will change in 1.0.12, as this should be able to be
called at any time.
</para>
</refsect1>
</refentry>
<!-- 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
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
-->