MongoDB\Driver\Query::__construct

(mongodb >=1.0.0)

MongoDB\Driver\Query::__constructConstruct new Query

Описание

final public MongoDB\Driver\Query::__construct ( array|object $filter [, array $queryOptions ] )

Список параметров

filter (array|object)

The search filter.

queryOptions

queryOptions
Option Type Description
awaitData bool Block rather than returning no data. After a period, time out. Useful for tailable cursor
batchSize integer The number of documents to return per batch
exhaust bool Stream the data down full blast in multiple "reply" packets. Faster when you are pulling down a lot of data and you know you want to retrieve it all
limit integer The number of documents to be returned
modifiers array Meta operators modifying the output or behavior of a query
noCursorTimeout bool Do not timeout a cursor that has been idle for more then 10minutes
oplogReplay bool Internal MongoDB Server flag
partial bool Get partial results from mongos if some shards are down (instead of throwing an error)
projection array|object Specifies the fields to return using booleans or projection operators
readConcern MongoDB\Driver\ReadConcern Level of isolation for querying replica sets and replica set shards. This option requires the WiredTiger storage engine and MongoDB 3.2 or later.
skip integer The number of documents to skip before returning
slaveOk bool Allow query of replica set secondaries
sort array|object The order in which to return matching documents
tailable bool Cursor will not be closed when the last data is retrieved. You can resume this cursor later

Ошибки

Примеры

Пример #1 MongoDB\Driver\Query::__construct() example

<?php
$filter 
= array();
$options = array(
    
/* Only return the following fields in the matching documents */
    
"projection" => array(
        
"title" => 1,
        
"article" => 1,
    ),
    
"sort" => array(
        
"views" => -1,
    ),
    
"modifiers" => array(
        
'$comment'   => "This is a query comment",
        
'$maxTimeMS' => 100,
    ),
);

$query = new MongoDB\Driver\Query($filter$options);

$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$readPreference = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY);
$cursor $manager->executeQuery("databaseName.collectionName"$query$readPreference);

foreach(
$cursor as $document) {
    
var_dump($document);
}

?>

Смотрите также

Коментарии

404 Not Found

404 Not Found


nginx

    Поддержать сайт на родительском проекте КГБ