readConcernAsDocument() public static method

Converts a ReadConcern instance to a stdClass for use in a BSON document.
See also: https://jira.mongodb.org/browse/PHPC-498
public static readConcernAsDocument ( MongoDB\Driver\ReadConcern $readConcern ) : stdClass
$readConcern MongoDB\Driver\ReadConcern Read concern
return stdClass
Example #1
0
 /**
  * Create the count command.
  *
  * @param Server $server
  *
  * @return Command
  */
 private function createCommand(Server $server)
 {
     $cmd = ['count' => $this->collectionName];
     if (!empty($this->filter)) {
         $cmd['query'] = (object) $this->filter;
     }
     foreach (['hint', 'limit', 'maxTimeMS', 'skip'] as $option) {
         if (isset($this->options[$option])) {
             $cmd[$option] = $this->options[$option];
         }
     }
     if (isset($this->options['readConcern']) && Functions::serverSupportsFeature($server, self::$wireVersionForReadConcern)) {
         $cmd['readConcern'] = Functions::readConcernAsDocument($this->options['readConcern']);
     }
     return new Command($cmd);
 }
Example #2
0
 /**
  * Create the distinct command.
  *
  * @param Server $server
  *
  * @return Command
  */
 private function createCommand(Server $server)
 {
     $cmd = ['distinct' => $this->collectionName, 'key' => $this->fieldName];
     if (!empty($this->filter)) {
         $cmd['query'] = (object) $this->filter;
     }
     if (isset($this->options['maxTimeMS'])) {
         $cmd['maxTimeMS'] = $this->options['maxTimeMS'];
     }
     if (isset($this->options['readConcern']) && Functions::serverSupportsFeature($server, self::$wireVersionForReadConcern)) {
         $cmd['readConcern'] = Functions::readConcernAsDocument($this->options['readConcern']);
     }
     return new Command($cmd);
 }
Example #3
0
 /**
  * Create the aggregate command.
  *
  * @param Server  $server
  * @param boolean $isCursorSupported
  *
  * @return Command
  */
 private function createCommand(Server $server, $isCursorSupported)
 {
     $cmd = ['aggregate' => $this->collectionName, 'pipeline' => $this->pipeline];
     // Servers < 2.6 do not support any command options
     if (!$isCursorSupported) {
         return new Command($cmd);
     }
     $cmd['allowDiskUse'] = $this->options['allowDiskUse'];
     if (isset($this->options['bypassDocumentValidation']) && Functions::serverSupportsFeature($server, self::$wireVersionForDocumentLevelValidation)) {
         $cmd['bypassDocumentValidation'] = $this->options['bypassDocumentValidation'];
     }
     if (isset($this->options['maxTimeMS'])) {
         $cmd['maxTimeMS'] = $this->options['maxTimeMS'];
     }
     if (isset($this->options['readConcern']) && Functions::serverSupportsFeature($server, self::$wireVersionForReadConcern)) {
         $cmd['readConcern'] = Functions::readConcernAsDocument($this->options['readConcern']);
     }
     if ($this->options['useCursor']) {
         $cmd['cursor'] = isset($this->options["batchSize"]) ? ['batchSize' => $this->options["batchSize"]] : new stdClass();
     }
     return new Command($cmd);
 }