php-doc-en/reference/mongo/mongocursor/count.xml
Jakub Vrana 2ee99d1e90 Fix protos
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@308234 c90b9560-bf6c-de11-be94-00142212c4b1
2011-02-10 22:48:53 +00:00

110 lines
2.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="mongocursor.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>MongoCursor::count</refname>
<refpurpose>Counts the number of results for this query</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>int</type><methodname>MongoCursor::count</methodname>
<methodparam choice="opt"><type>bool</type><parameter>foundOnly</parameter><initializer>&false;</initializer></methodparam>
</methodsynopsis>
<para>
This method does not affect the state of the cursor: if you haven't queried
yet, you can still apply limits, skips, etc. If you have started iterating
through results, it will not move the current position of the cursor. If you
have exhasted the cursor, it will not reset it.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term>
<parameter>foundOnly</parameter>
</term>
<listitem>
<para>
Send cursor limit and skip information to the count function, if applicable.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The number of documents returned by this cursor's query.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>MongoCursor::count</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$collection->insert(array('x'=>1));
$collection->insert(array('x'=>2));
$collection->insert(array('x'=>3));
$cursor = $collection->find();
var_dump($cursor->count());
var_dump($cursor->count(true));
$cursor->limit(2);
var_dump($cursor->count());
var_dump($cursor->count(true));
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
int(3)
int(3)
int(3)
int(2)
]]>
</screen>
</example>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Throws <classname>MongoConnectionException</classname> if it cannot reach the
database.
</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
-->