Phalcon\Db\Adapter\MongoDB\Functions::readConcernAsDocument PHP Method

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
    public static function readConcernAsDocument(ReadConcern $readConcern)
    {
        $document = [];
        if ($readConcern->getLevel() !== null) {
            $document['level'] = $readConcern->getLevel();
        }
        return (object) $document;
    }

Usage Example

Ejemplo n.º 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);
 }
All Usage Examples Of Phalcon\Db\Adapter\MongoDB\Functions::readConcernAsDocument