MongoCursor::setFlag
(PECL mongo >=1.2.11)
MongoCursor::setFlag — Sets arbitrary flags in case there is no method available the specific flag
Description
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.
Parameters
-
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
).
Changelog
Version | Description |
---|---|
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. |
Examples
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
?>
See Also
- 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
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-mongocursor.setflag.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.