芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/giga.mgaplay.com.br/vendor/mongodb/mongodb/src/Operation/Update.php
false, 'upsert' => false, ]; if (isset($options['arrayFilters']) && ! is_array($options['arrayFilters'])) { throw InvalidArgumentException::invalidType('"arrayFilters" option', $options['arrayFilters'], 'array'); } if (isset($options['bypassDocumentValidation']) && ! is_bool($options['bypassDocumentValidation'])) { throw InvalidArgumentException::invalidType('"bypassDocumentValidation" option', $options['bypassDocumentValidation'], 'boolean'); } if (isset($options['collation']) && ! is_array($options['collation']) && ! is_object($options['collation'])) { throw InvalidArgumentException::invalidType('"collation" option', $options['collation'], 'array or object'); } if (isset($options['hint']) && ! is_string($options['hint']) && ! is_array($options['hint']) && ! is_object($options['hint'])) { throw InvalidArgumentException::invalidType('"hint" option', $options['hint'], ['string', 'array', 'object']); } if (! is_bool($options['multi'])) { throw InvalidArgumentException::invalidType('"multi" option', $options['multi'], 'boolean'); } if ($options['multi'] && ! is_first_key_operator($update) && ! is_pipeline($update)) { throw new InvalidArgumentException('"multi" option cannot be true if $update is a replacement document'); } if (isset($options['session']) && ! $options['session'] instanceof Session) { throw InvalidArgumentException::invalidType('"session" option', $options['session'], Session::class); } if (! is_bool($options['upsert'])) { throw InvalidArgumentException::invalidType('"upsert" option', $options['upsert'], 'boolean'); } if (isset($options['writeConcern']) && ! $options['writeConcern'] instanceof WriteConcern) { throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], WriteConcern::class); } if (isset($options['writeConcern']) && $options['writeConcern']->isDefault()) { unset($options['writeConcern']); } $this->databaseName = (string) $databaseName; $this->collectionName = (string) $collectionName; $this->filter = $filter; $this->update = $update; $this->options = $options; } /** * Execute the operation. * * @see Executable::execute() * @param Server $server * @return UpdateResult * @throws UnsupportedException if array filters or collation is used and unsupported * @throws DriverRuntimeException for other driver errors (e.g. connection errors) */ public function execute(Server $server) { if (isset($this->options['arrayFilters']) && ! server_supports_feature($server, self::$wireVersionForArrayFilters)) { throw UnsupportedException::arrayFiltersNotSupported(); } if (isset($this->options['collation']) && ! server_supports_feature($server, self::$wireVersionForCollation)) { throw UnsupportedException::collationNotSupported(); } /* Server versions >= 3.4.0 raise errors for unsupported update options. * For previous versions, the CRUD spec requires a client-side error. */ if (isset($this->options['hint']) && ! server_supports_feature($server, self::$wireVersionForUnsupportedOptionServerSideError)) { throw UnsupportedException::hintNotSupported(); } /* CRUD spec requires a client-side error when using "hint" with an * unacknowledged write concern on an unsupported server. */ if ( isset($this->options['writeConcern']) && ! is_write_concern_acknowledged($this->options['writeConcern']) && isset($this->options['hint']) && ! server_supports_feature($server, self::$wireVersionForHint) ) { throw UnsupportedException::hintNotSupported(); } $inTransaction = isset($this->options['session']) && $this->options['session']->isInTransaction(); if ($inTransaction && isset($this->options['writeConcern'])) { throw UnsupportedException::writeConcernNotSupportedInTransaction(); } $bulkOptions = []; if ( ! empty($this->options['bypassDocumentValidation']) && server_supports_feature($server, self::$wireVersionForDocumentLevelValidation) ) { $bulkOptions['bypassDocumentValidation'] = $this->options['bypassDocumentValidation']; } $bulk = new Bulk($bulkOptions); $bulk->update($this->filter, $this->update, $this->createUpdateOptions()); $writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $this->createExecuteOptions()); return new UpdateResult($writeResult); } /** * Returns the command document for this operation. * * @see Explainable::getCommandDocument() * @param Server $server * @return array */ public function getCommandDocument(Server $server) { $cmd = ['update' => $this->collectionName, 'updates' => [['q' => $this->filter, 'u' => $this->update] + $this->createUpdateOptions()]]; if (isset($this->options['writeConcern'])) { $cmd['writeConcern'] = $this->options['writeConcern']; } if ( ! empty($this->options['bypassDocumentValidation']) && server_supports_feature($server, self::$wireVersionForDocumentLevelValidation) ) { $cmd['bypassDocumentValidation'] = $this->options['bypassDocumentValidation']; } return $cmd; } /** * Create options for executing the bulk write. * * @see http://php.net/manual/en/mongodb-driver-server.executebulkwrite.php * @return array */ private function createExecuteOptions() { $options = []; if (isset($this->options['session'])) { $options['session'] = $this->options['session']; } if (isset($this->options['writeConcern'])) { $options['writeConcern'] = $this->options['writeConcern']; } return $options; } /** * Create options for the update command. * * Note that these options are different from the bulk write options, which * are created in createExecuteOptions(). * * @return array */ private function createUpdateOptions() { $updateOptions = [ 'multi' => $this->options['multi'], 'upsert' => $this->options['upsert'], ]; foreach (['arrayFilters', 'hint'] as $option) { if (isset($this->options[$option])) { $updateOptions[$option] = $this->options[$option]; } } if (isset($this->options['collation'])) { $updateOptions['collation'] = (object) $this->options['collation']; } return $updateOptions; } }