downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

MongoCursor::current> <MongoCursor::__construct
Last updated: Fri, 20 Nov 2009

view this page in

MongoCursor::count

(PECL mongo >=0.9.2)

MongoCursor::countCounts the number of results for this query

Description

public int MongoCursor::count ([ boolean $all = FALSE ] )

Parameters

all

Send cursor limit and skip information to the count function, if applicable.

Return Values

The number of documents returned by this cursor's query.

Examples

Example #1 MongoCursor::count() example

<?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));

?>

The above example will output something similar to:

int(3)
int(3)
int(3)
int(2)

Errors/Exceptions

Throws MongoConnectionException if it cannot reach the database.



add a note add a note User Contributed Notes
MongoCursor::count
There are no user contributed notes for this page.

MongoCursor::current> <MongoCursor::__construct
Last updated: Fri, 20 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites