0
    $startplushowmany=$startfrom+$howmany; //$startplush is 40
    $cursor=$cursor->limit($startplushowmany);  

    $numberReturned=$cursor->count();   //$numberReturned is 45

我不能给你看 $cursor 的内容,因为 $cursor 没有实现 _toString。请让我知道该怎么做。

现在 $cursor 中的查询由以下命令定义: $cursor = $collection->find($rangeQuery, $field);

$rangeQuery 在哪里

(string:592) Array
(
    [LongitudeLatitude] => Array
        (
            [$within] => Array
                (
                    [$center] => Array
                        (
                            [0] => Array
                                (
                                    [0] => 106.772835
                                    [1] => -6.186753
                                )

                            [1] => 0.044983732050783
                        )

                )

        )

    [indexContents] => bas
    [Prominent] => Array
        (
            [$gte] => 15
        )

)

$字段是

(string:39) Array
(
    [LongitudeLatitude] => 1
)
4

1 回答 1

1

您需要使用布尔标志来考虑计数限制,否则它会给出实际计数

$numberReturned=$cursor->count(true);

引用PHP doc中的示例:

<?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)
于 2012-08-22T06:09:54.107 回答