(PECL mongo >=1.5.0)
Examples:
Adding options to MongoCommandCursor

A MongoCommandCursor has two "life stages": pre- and post- command. When a cursor is created, it has not yet contacted the database, so it is in its pre-command state. When the client first attempts to get a result (by calling MongoCommandCursor::rewind(), directly or indirectly), the cursor moves into the post-command state.

The command cursor's batch size and socket timeout may be configured in both the pre- and post- command states.

<?php

$cursor = new MongoCommandCursor(...);

$cursor = $cursor->batchSize( 4 );

foreach ($cursor as $result) {
    var_dump($result);
}
?>

MongoCommandCursor::current
  • References/PHP/Function/Database/MongoDB driver/MongoCommandCursor

(PECL mongo >=1.5.0) Returns the current element

2025-01-10 15:47:30
MongoCommandCursor::key
  • References/PHP/Function/Database/MongoDB driver/MongoCommandCursor

(PECL mongo >=1.5.0) Returns the current result's index within the result set

2025-01-10 15:47:30
MongoCommandCursor::batchSize
  • References/PHP/Function/Database/MongoDB driver/MongoCommandCursor

(PECL mongo >=1.5.0) Limits the number of elements returned in one batch.

2025-01-10 15:47:30