2012-08-22 57 views
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 
) 

回答

1

你需要使用一個布爾標誌,具有計數採取限制考慮,否則給人的實際 count

$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) 
+0

哪裏是PHP的文檔? –

+0

爲PHP文檔添加鏈接。 – DhruvPathak