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

search for in the

MongoCollection::createDBRef> <MongoCollection::__construct
[edit] Last updated: Fri, 18 Sep 2009

view this page in

MongoCollection::count

(PECL mongo >=0.9.0)

MongoCollection::countCounts the number of documents in this collection

Описание

public int MongoCollection::count ([ array $query = array() [, array $fields = array() ]] )

Параметри

query

Only count documents matching this query.

fields

Only count documents with these fields.

Връщани стойности

Returns the number of documents.

Примери

Example #1 MongoCollection::count() example

<?php

$collection
->insert(array('x'=>1));
$collection->insert(array('x'=>2));
$collection->insert(array('x'=>3'y'=>1));

var_dump($collection->count());
var_dump($collection->count(array('x'=>1)));
var_dump($collection->count(array(), array('z'=>1)));

?>

Примерът по-горе ще изведе нещо подобно на:

int(3)
int(1)
int(0)


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

 
show source | credits | stats | sitemap | contact | advertising | mirror sites