/**
  * Returns information for all indexes for this collection by querying the
  * "system.indexes" collection (MongoDB <3.0).
  *
  * @param Server $server
  * @return IndexInfoIteratorIterator
  */
 private function executeLegacy(Server $server)
 {
     $filter = array('ns' => $this->databaseName . '.' . $this->collectionName);
     $options = isset($this->options['maxTimeMS']) ? array('modifiers' => array('$maxTimeMS' => $this->options['maxTimeMS'])) : array();
     $cursor = $server->executeQuery($this->databaseName . '.system.indexes', new Query($filter, $options));
     $cursor->setTypeMap(array('root' => 'array', 'document' => 'array'));
     return new IndexInfoIteratorIterator($cursor);
 }
Example #2
0
 /**
  * Returns information for all collections in this database by querying the
  * "system.namespaces" collection (MongoDB <3.0).
  *
  * @param Server $server
  *
  * @return CollectionInfoLegacyIterator
  * @throws InvalidArgumentException if filter.name is not a string.
  */
 private function executeLegacy(Server $server)
 {
     $filter = empty($this->options['filter']) ? [] : (array) $this->options['filter'];
     if (array_key_exists('name', $filter)) {
         if (!is_string($filter['name'])) {
             throw InvalidArgumentException::invalidType('filter name for MongoDB <3.0', $filter['name'], 'string');
         }
         $filter['name'] = $this->databaseName . '.' . $filter['name'];
     }
     $options = isset($this->options['maxTimeMS']) ? ['modifiers' => ['$maxTimeMS' => $this->options['maxTimeMS']]] : [];
     $cursor = $server->executeQuery($this->databaseName . '.system.namespaces', new Query($filter, $options));
     $cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
     return new CollectionInfoLegacyIterator($cursor);
 }
Example #3
0
 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return Cursor
  */
 public function execute(Server $server)
 {
     $readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
     return $server->executeQuery($this->databaseName . '.' . $this->collectionName, $this->createQuery(), $readPreference);
 }
Example #4
0
 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return Cursor
  */
 public function execute(Server $server)
 {
     $readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
     $cursor = $server->executeQuery($this->databaseName . '.' . $this->collectionName, $this->createQuery(), $readPreference);
     if (isset($this->options['typeMap'])) {
         $cursor->setTypeMap($this->options['typeMap']);
     }
     return $cursor;
 }
 /**
  * Execute the operation.
  *
  * @see Executable::execute()
  * @param Server $server
  * @return Cursor
  */
 public function execute(Server $server)
 {
     return $server->executeQuery($this->databaseName . '.' . $this->collectionName, $this->createQuery());
 }