芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/cache/stores/mongodb/MongoDB/Operation/ListIndexes.php
databaseName = (string) $databaseName; $this->collectionName = (string) $collectionName; $this->options = $options; } /** * Execute the operation. * * @see Executable::execute() * @param Server $server * @return IndexInfoIterator * @throws DriverRuntimeException for other driver errors (e.g. connection errors) */ public function execute(Server $server) { return $this->executeCommand($server); } /** * Create options for executing the command. * * Note: read preference is intentionally omitted, as the spec requires that * the command be executed on the primary. * * @see http://php.net/manual/en/mongodb-driver-server.executecommand.php * @return array */ private function createOptions() { $options = []; if (isset($this->options['session'])) { $options['session'] = $this->options['session']; } return $options; } /** * Returns information for all indexes for this collection using the * listIndexes command. * * @param Server $server * @return IndexInfoIteratorIterator * @throws DriverRuntimeException for other driver errors (e.g. connection errors) */ private function executeCommand(Server $server) { $cmd = ['listIndexes' => $this->collectionName]; if (isset($this->options['maxTimeMS'])) { $cmd['maxTimeMS'] = $this->options['maxTimeMS']; } try { $cursor = $server->executeCommand($this->databaseName, new Command($cmd), $this->createOptions()); } catch (DriverRuntimeException $e) { /* The server may return an error if the collection does not exist. * Check for possible error codes (see: SERVER-20463) and return an * empty iterator instead of throwing. */ if ($e->getCode() === self::$errorCodeNamespaceNotFound || $e->getCode() === self::$errorCodeDatabaseNotFound) { return new IndexInfoIteratorIterator(new EmptyIterator); } throw $e; } $cursor->setTypeMap(['root' => 'array', 'document' => 'array']); return new IndexInfoIteratorIterator(new CachingIterator($cursor)); } }