|
update : 2015.11.03
php.shukuma.com검색:
|
MongoCursor::addOption(PECL mongo >=1.0.4) MongoCursor::addOption — Adds a top-level key/value pair to a query 설명This is an advanced function and should not be used unless you know what you're doing. A query can optionally be nested in a "query" field if other options, such as a sort or hint, are given. For instance, adding a sort causes the query to become a subfield of a bigger query object, like:
<?phpThis method is for adding a top-level field to a query. It makes the query a subobject (if it isn't already) and adds the key/value pair of your chosing to the top level. Warning
It cannot be used to add extra criteria to a query on the fly. For instance, this will not work:
<?php인수
반환값Returns this cursor. 오류/예외Throws MongoCursorException if this cursor has started iterating. 예제Example #1 Adding a comment with MongoCursor::addOption() example MongoDB supports special options to be send to the server. The shell uses the _addSpecial option to send a $comment to the server. This comment will show up in the profiling log (for slow queries f.e.). In the PHP driver, you use the MongoCursor::addOption() method.
<?php위 예제의 출력 예시:
{
"op" : "query",
"ns" : "demo.demo",
"query" : {
"$query" : {
},
"$comment" : "This comment will show up in the profiling log"
},
"cursorid" : 168463566447,
"ntoreturn" : 0,
"ntoskip" : 0,
"nscanned" : 101,
"nscannedObjects" : 101,
"keyUpdates" : 0,
"numYield" : 0,
…
Example #2 MongoCursor::addOption() example Using MongoCursor::skip() to skip over millions of results can become slow. One way around this is to use $min or $max options for the query. These can be handy, but they require an index on exactly the fields being searched for. This is an example of how to use $min as an alternative to MongoCursor::skip().
<?php |