芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/public_html/cepali/cache/stores/mongodb/MongoDB/Operation/Find.php
isDefault()) { unset($options['readConcern']); } if (isset($options['snapshot'])) { trigger_error('The "snapshot" option is deprecated and will be removed in a future release', E_USER_DEPRECATED); } if (isset($options['maxScan'])) { trigger_error('The "maxScan" option is deprecated and will be removed in a future release', E_USER_DEPRECATED); } $this->databaseName = (string) $databaseName; $this->collectionName = (string) $collectionName; $this->filter = $filter; $this->options = $options; } /** * Execute the operation. * * @see Executable::execute() * @param Server $server * @return Cursor * @throws UnsupportedException if collation or read concern is used and unsupported * @throws DriverRuntimeException for other driver errors (e.g. connection errors) */ public function execute(Server $server) { if (isset($this->options['collation']) && ! \MongoDB\server_supports_feature($server, self::$wireVersionForCollation)) { throw UnsupportedException::collationNotSupported(); } if (isset($this->options['readConcern']) && ! \MongoDB\server_supports_feature($server, self::$wireVersionForReadConcern)) { throw UnsupportedException::readConcernNotSupported(); } $cursor = $server->executeQuery($this->databaseName . '.' . $this->collectionName, new Query($this->filter, $this->createQueryOptions()), $this->createExecuteOptions()); if (isset($this->options['typeMap'])) { $cursor->setTypeMap($this->options['typeMap']); } return $cursor; } public function getCommandDocument(Server $server) { return $this->createCommandDocument(); } /** * Construct a command document for Find */ private function createCommandDocument() { $cmd = ['find' => $this->collectionName, 'filter' => (object) $this->filter]; $options = $this->createQueryOptions(); if (empty($options)) { return $cmd; } // maxAwaitTimeMS is a Query level option so should not be considered here unset($options['maxAwaitTimeMS']); $modifierFallback = [ ['allowPartialResults', 'partial'], ['comment', '$comment'], ['hint', '$hint'], ['maxScan', '$maxScan'], ['max', '$max'], ['maxTimeMS', '$maxTimeMS'], ['min', '$min'], ['returnKey', '$returnKey'], ['showRecordId', '$showDiskLoc'], ['sort', '$orderby'], ['snapshot', '$snapshot'], ]; foreach ($modifierFallback as $modifier) { if ( ! isset($options[$modifier[0]]) && isset($options['modifiers'][$modifier[1]])) { $options[$modifier[0]] = $options['modifiers'][$modifier[1]]; } } unset($options['modifiers']); return $cmd + $options; } /** * Create options for executing the command. * * @see http://php.net/manual/en/mongodb-driver-server.executequery.php * @return array */ private function createExecuteOptions() { $options = []; if (isset($this->options['readPreference'])) { $options['readPreference'] = $this->options['readPreference']; } if (isset($this->options['session'])) { $options['session'] = $this->options['session']; } return $options; } /** * Create options for the find query. * * Note that these are separate from the options for executing the command, * which are created in createExecuteOptions(). * * @return array */ private function createQueryOptions() { $options = []; if (isset($this->options['cursorType'])) { if ($this->options['cursorType'] === self::TAILABLE) { $options['tailable'] = true; } if ($this->options['cursorType'] === self::TAILABLE_AWAIT) { $options['tailable'] = true; $options['awaitData'] = true; } } foreach (['allowPartialResults', 'batchSize', 'comment', 'hint', 'limit', 'maxAwaitTimeMS', 'maxScan', 'maxTimeMS', 'noCursorTimeout', 'oplogReplay', 'projection', 'readConcern', 'returnKey', 'showRecordId', 'skip', 'snapshot', 'sort'] as $option) { if (isset($this->options[$option])) { $options[$option] = $this->options[$option]; } } foreach (['collation', 'max', 'min'] as $option) { if (isset($this->options[$option])) { $options[$option] = (object) $this->options[$option]; } } $modifiers = empty($this->options['modifiers']) ? [] : (array) $this->options['modifiers']; if ( ! empty($modifiers)) { $options['modifiers'] = $modifiers; } return $options; } }