Added docs for MongoCursor::awaitData() and MongoCursor::setFlag() that are new in 1.2.11/1.3.0.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@326156 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Derick Rethans 2012-06-13 15:40:47 +00:00
parent 8c89316af7
commit a8906b51ea
3 changed files with 256 additions and 0 deletions

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 317663 $ -->
<refentry xml:id="mongocursor.awaitdata" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>MongoCursor::awaitData</refname>
<refpurpose>Sets whether this cursor will wait for a while for a tailable cursor to return more data</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>MongoCursor</type><methodname>MongoCursor::awaitData</methodname>
<methodparam choice="opt"><type>bool</type><parameter>wait</parameter><initializer>true</initializer></methodparam>
</methodsynopsis>
<para>
This method is to be used with tailable cursors. If we are at the end of
the data, block for a while rather than returning no data. After a timeout
period, we do return as normal.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term>
<parameter>wait</parameter>
</term>
<listitem>
<para>
If the cursor should wait for more data to become available.
</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.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>MongoCursor::awaitData</function> example</title>
<para>
In this example we tail the "oplog" and instead of sleeping during every
iteration, we set the <function>MongoCursor::awaitData</function> option.
<function>MongoCursor::hasNext</function> will now block until there is
more data available.
</para>
<programlisting role="php">
<![CDATA[
<?php
$m = new Mongo( 'mongodb://localhost:13000', array( 'replSet' => 'seta' ) );
$c = $m->local->selectCollection( 'oplog.rs' );
$cursor = $c->find( array( 'ns' => 'demo.article', 'op' => 'i' ) );
$cursor->tailable( true );
$cursor->awaitData( true );
while (true) {
if (!$cursor->hasNext()) {
// we've read all the results, exit
if ($cursor->dead()) {
break;
}
} else {
var_dump( $cursor->getNext() );
}
}
?>
]]>
</programlisting>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
MongoDB core docs on <link xlink:href="&url.mongodb.dochub.tailable;">tailable cursors</link>.
</para>
<para>
<simplelist>
<member><function>MongoCursor::tailable</function></member>
</simplelist>
</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
-->

View file

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 317663 $ -->
<refentry xml:id="mongocursor.setflag" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>MongoCursor::setFlag</refname>
<refpurpose>Sets arbitrary flags in case there is no method available the specific flag</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>MongoCursor</type><methodname>MongoCursor::setFlag</methodname>
<methodparam><type>bool</type><parameter>flag</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>set</parameter><initializer>true</initializer></methodparam>
</methodsynopsis>
<para>
The <classname>MongoCursor</classname> class has several methods for
setting flags on the query object. This method is available in case the
MongoDB wire protocol has acquired a new flag, and the driver has not been
updated with a method for this new flag. In all other cases, the method
should be used. See the "See also" section for available methods.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term>
<parameter>flag</parameter>
</term>
<listitem>
<para>
Which flag to set. You can not set flag 3 (OPLOG REPLAY) or flag 6
(EXHAUST) as the driver does not know how to handle them. You will get
a warning if you try to use those. For available flags, please refer to
the wire protocol
<link xlink:href="&url.mongodb.dochub.wireprotocol;#MongoWireProtocol-OPQUERY">documentation</link>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>set</parameter>
</term>
<listitem>
<para>
Whether the flag should be set (&true;) or unset (&false;).
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns this cursor.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Shows a warning when an unsupport flag is attempted to be set.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>MongoCursor::setFlag</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$m = new Mongo( 'mongodb://localhost:13000', array( 'replSet' => 'seta' ) );
$c = $m->local->selectCollection( 'oplog.rs' );
$cursor = $c->find( array( 'ns' => 'demo.article', 'op' => 'i' ) );
$cursor->setFlag( 1, true ); // sets the tailable flag
$cursor->setFlag( 5, true ); // sets the await data flag
?>
]]>
</programlisting>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
MongoDB core docs on
<link xlink:href="&url.mongodb.dochub.wireprotocol;#MongoWireProtocol-OPQUERY">wire protocol query flags</link>.
</para>
<para>
<simplelist>
<member><function>MongoCursor::tailable</function></member>
<member><function>MongoCursor::slaveOkay</function></member>
<member><function>MongoCursor::immortal</function></member>
<member><function>MongoCursor::awaitData</function></member>
<member><function>MongoCursor::partial</function></member>
</simplelist>
</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
-->

View file

@ -93,6 +93,17 @@ while (1) {
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
MongoDB core docs on <link xlink:href="&url.mongodb.dochub.tailable;">tailable cursors</link>.
</para>
<para>
<simplelist>
<member><function>MongoCursor::awaitData</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables: