Docs Menu
Docs Home
/ / /
PHP Library Manual
/ / /

MongoDB\ChangeStream::getCursorId()

On this page

  • Definition
  • Return Values
  • Examples
  • See Also
MongoDB\ChangeStream::getCursorId()

Returns the change stream cursor's ID.

function getCursorId(): MongoDB\Driver\CursorId

A MongoDB\Driver\CursorId object.

This example reports the cursor ID for a change stream.

<?php
$uri = 'mongodb://rs1.example.com,rs2.example.com/?replicaSet=myReplicaSet';
$collection = (new MongoDB\Client($uri))->test->inventory;
$changeStream = $collection->watch();
var_dump($changeStream->getCursorId());

The output would then resemble:

object(MongoDB\Driver\CursorId)#5 (1) {
["id"]=>
int(8462642181784669708)
}
  • MongoDB\Client::watch()

  • MongoDB\Collection::watch()

  • MongoDB\Database::watch()

  • MongoDB\Driver\CursorId

  • MongoDB\Driver\Cursor::getId()

Back

current()