PHPKonf 2020 Online

MongoCommandCursor::info

(PECL mongo >=1.5.0)

MongoCommandCursor::infoGets information about the cursor's creation and iteration

Açıklama

public MongoCommandCursor::info ( ) : array

This can be called before or after the cursor has started iterating.

Değiştirgeler

Bu işlevin değiştirgesi yoktur.

Dönen Değerler

Returns the namespace, batch size, limit, skip, flags, query, and projected fields for this cursor. If the cursor has started iterating, additional information about iteration and the connection will be included.

Örnekler

Örnek 1 MongoCommandCursor::info() example

<?php
$m 
= new MongoClient();

$cursor = new MongoCommandCursor(
    
$m// MongoClient object
    
'demo.cities'// namespace
    
[
        
'aggregate' => 'cities',
        
'pipeline' => [ [ '$match' => [ '_id' => [ '$exists' => true ] ] ] ],
        
'cursor' => [ 'batchSize' => ],
    ]
);

echo 
"Before iteration started:\n";
var_dump($cursor->info());

echo 
"\nAfter iteration started:\n";
$cursor->rewind();
var_dump($cursor->info());

?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

Before iteration started:
array(8) {
  ["ns"]=>
  string(11) "demo.cities"
  ["limit"]=>
  int(0)
  ["batchSize"]=>
  int(0)
  ["skip"]=>
  int(0)
  ["flags"]=>
  int(0)
  ["query"]=>
  array(3) {
    ["aggregate"]=>
    string(6) "cities"
    ["pipeline"]=>
    array(1) {
      [0]=>
      array(1) {
        ["$match"]=>
        array(1) {
          ["_id"]=>
          array(1) {
            ["$exists"]=>
            bool(true)
          }
        }
      }
    }
    ["cursor"]=>
    array(1) {
      ["batchSize"]=>
      int(1)
    }
  }
  ["fields"]=>
  NULL
  ["started_iterating"]=>
  bool(false)
}

After iteration started:
array(17) {
  ["ns"]=>
  string(11) "demo.cities"
  ["limit"]=>
  int(0)
  ["batchSize"]=>
  int(0)
  ["skip"]=>
  int(0)
  ["flags"]=>
  int(0)
  ["query"]=>
  array(3) {
    ["aggregate"]=>
    string(6) "cities"
    ["pipeline"]=>
    array(1) {
      [0]=>
      array(1) {
        ["$match"]=>
        array(1) {
          ["_id"]=>
          array(1) {
            ["$exists"]=>
            bool(true)
          }
        }
      }
    }
    ["cursor"]=>
    array(1) {
      ["batchSize"]=>
      int(1)
    }
  }
  ["fields"]=>
  NULL
  ["started_iterating"]=>
  bool(true)
  ["id"]=>
  int(185840310129)
  ["at"]=>
  int(0)
  ["numReturned"]=>
  int(0)
  ["server"]=>
  string(25) "localhost:27017;-;.;23991"
  ["host"]=>
  string(9) "localhost"
  ["port"]=>
  int(27017)
  ["connection_type_desc"]=>
  string(10) "STANDALONE"
  ["firstBatchAt"]=>
  int(0)
  ["firstBatchNumReturned"]=>
  int(1)
}

Ayrıca Bakınız

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top