Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетил 310131 программист и 5513 роботов. Сейчас ищут 2889 программистов ...
Приступая к работе

MongoCursor::count - Counts the number of results for this query

Вернуться к: MongoCursor

MongoCursor::count

(PECL mongo >=0.9.2)

MongoCursor::count — Counts the number of results for this query

Описание

public int MongoCursor::count ([ bool $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.

Список параметров

foundOnly

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

Возвращаемые значения

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

Примеры

Пример #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));

?>

Результатом выполнения данного примера будет что-то подобное:

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

Ошибки

Throws MongoConnectionException if it cannot reach the database.



Вернуться к: MongoCursor

© 2026 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты
Разработка компании ODWR