Php/docs/mongocursor.setflag
MongoCursor::setFlag
(PECL mongo >=1.2.11)
MongoCursor::setFlag — Sets arbitrary flags in case there is no method available the specific flag
说明
public MongoCursor::setFlag
( int $flag
[, bool $set
= true
] ) : MongoCursor
The MongoCursor class has several methods for setting flags on the query object. This method is available in case the MongoDB wire protocol has acquired a new flag, and the driver has not been updated with a method for this new flag. In all other cases, the method should be used. See the "See also" section for available methods.
参数
flag
- Which flag to set. You can not set flag 6 (EXHAUST) as the driver does not know how to handle them. You will get a warning if you try to use this flag. For available flags, please refer to the wire protocol » documentation.
set
- Whether the flag should be set (
true
) or unset (false
).
返回值
Returns this cursor.
错误/异常
Shows a warning when an unsupport flag is attempted to be set.
更新日志
版本 | 说明 |
---|---|
PECL mongo 1.4.0 | Support for flag 3 (OPLOG_REPLAY) is added. Versions before 1.4.0
would throw a warning saying that the flag is unsupported. |
范例
Example #1 MongoCursor::setFlag() example
<?php$m = new MongoClient( 'mongodb://localhost:13000', array( 'replSet' => 'seta' ) );$c = $m->local->selectCollection( 'oplog.rs' );$cursor = $c->find( array( 'ns' => 'demo.article', 'op' => 'i' ) );$cursor->setFlag( 1, true ); // sets the tailable flag$cursor->setFlag( 5, true ); // sets the await data flag?>
参见
- MongoCursor::tailable() - Sets whether this cursor will be left open after fetching the last results
- MongoCursor::immortal() - Sets whether this cursor will timeout
- MongoCursor::awaitData() - Sets whether this cursor will wait for a while for a tailable cursor to return more data
- MongoCursor::partial() - If this query should fetch partial results from mongos if a shard is down
- MongoDB core docs on» wire protocol query flags