php-doc-en/reference/mongo/mongocollection/count.xml
Kristina Chodorow 24c0366232 clarified cursor count behavior
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@303733 c90b9560-bf6c-de11-be94-00142212c4b1
2010-09-23 15:12:19 +00:00

135 lines
3.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="mongocollection.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>MongoCollection::count</refname>
<refpurpose>Counts the number of documents in this collection</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>int</type><methodname>MongoCollection::count</methodname>
<methodparam choice="opt"><type>array</type><parameter>query</parameter><initializer>array()</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>limit</parameter><initializer>0</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>skip</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term>
<parameter>query</parameter>
</term>
<listitem>
<para>
Associative array or object with fields to match.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>limit</parameter>
</term>
<listitem>
<para>
Specifies an upper limit to the number returned.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>skip</parameter>
</term>
<listitem>
<para>
Specifies a number of results to skip before starting the count.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the number of documents matching the query.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>1.0.7</entry>
<entry>
Added <literal>limit</literal> and <literal>skip</literal> parameters.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>MongoCollection::count</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$collection->insert(array('x'=>1));
$collection->insert(array('x'=>2));
$collection->insert(array('x'=>3));
var_dump($collection->count());
var_dump($collection->count(array('x'=>1)));
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
int(3)
int(1)
]]>
</screen>
</example>
</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
-->