MongoDB\Driver\Cursor::isDead

(mongodb >=1.0.0)

MongoDB\Driver\Cursor::isDeadChecks if the cursor may have additional results

说明

final public MongoDB\Driver\Cursor::isDead ( void ) : bool

Checks whether the cursor may have additional results available to read. A cursor is initially "alive" but may become "dead" for any of the following reasons:

  • Advancing a non-tailable cursor did not return a document
  • The cursor encountered an error
  • The cursor read its last batch to completion
  • The cursor reached its configured limit
This is primarily useful with tailable cursors.

参数

此函数没有参数。

返回值

Returns TRUE if additional results are not available, and FALSE otherwise.

错误/异常

范例

Example #1 MongoDB\Driver\Cursor::isDead() example

<?php

$manager 
= new MongoDB\Driver\Manager("mongodb://localhost:27017");
$query = new MongoDB\Driver\Query([]);

$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$bulk->insert(['x' => 2]);
$bulk->insert(['x' => 3]);
$manager->executeBulkWrite('db.collection'$bulk);

$cursor $manager->executeQuery('db.collection'$query);

$iterator = new IteratorIterator($cursor);

$iterator->rewind();
var_dump($cursor->isDead());

$iterator->next();
var_dump($cursor->isDead());

$iterator->next();
var_dump($cursor->isDead());

$iterator->next();
var_dump($cursor->isDead());

?>

以上例程会输出:

bool(false)
bool(false)
bool(false)
bool(true)
相关文章
php mongodb driver the mongodb driver cursor classphp odbc 函数 checks if multiple results are availablephp mongocommandcursor checks if there are results that have not yet been sent from the databasephp mongocursor checks if there are results that have not yet been sent from the databasephp mongocursor checks if there are any more elements in this cursorphp mongocursorinterface checks if there are results that have not yet been sent from the databasephp mongodb driver cursor create a new cursor not used php mongodb driver cursor returns the id for this cursorphp mongodb driver cursor returns the server associated with this cursorphp mongodb driver cursor checks if the cursor may have additional resultsphp mongodb driver cursor returns an array containing all results for this cursorphp mongodb driver readconcern checks if this is the default read concernphp mongodb driver server checks if this server is an arbiter member of a replica setphp mongodb driver server checks if this server is a hidden member of a replica setphp mongodb driver server checks if this server is a passive member of a replica setphp mongodb driver server checks if this server is a primary member of a replica setphp mongodb driver server checks if this server is a secondary member of a replica setphp mongodb driver writeconcern checks if this is the default write concernphp mongodb driver writeconcernerror returns additional metadata for the writeconcernerrorphp solrquery if true solr includes the number of groups that have matched the query in the results
关注编程学问公众号