PHP Doku:: Counts the number of results for this query - mongocursor.count.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenMongoDB Native DriverCore ClassesThe MongoCursor classMongoCursor::count

Ein Service von Reinhard Neidl - Webprogrammierung.

The MongoCursor class

<<MongoCursor::__construct

MongoCursor::current>>

MongoCursor::count

(PECL mongo >=0.9.2)

MongoCursor::countCounts the number of results for this query

Beschreibung

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

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.

Parameter-Liste

foundOnly

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

Rückgabewerte

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

Beispiele

Beispiel #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));

?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

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

Fehler/Exceptions

Throws MongoConnectionException if it cannot reach the database.


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)