芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/giga.mgaplay.com.br/vendor/mongodb/mongodb/src/Operation/InsertMany.php
$document) { if ($i !== $expectedIndex) { throw new InvalidArgumentException(sprintf('$documents is not a list (unexpected index: "%s")', $i)); } if (! is_array($document) && ! is_object($document)) { throw InvalidArgumentException::invalidType(sprintf('$documents[%d]', $i), $document, 'array or object'); } $expectedIndex += 1; } $options += ['ordered' => true]; if (isset($options['bypassDocumentValidation']) && ! is_bool($options['bypassDocumentValidation'])) { throw InvalidArgumentException::invalidType('"bypassDocumentValidation" option', $options['bypassDocumentValidation'], 'boolean'); } if (! is_bool($options['ordered'])) { throw InvalidArgumentException::invalidType('"ordered" option', $options['ordered'], 'boolean'); } if (isset($options['session']) && ! $options['session'] instanceof Session) { throw InvalidArgumentException::invalidType('"session" option', $options['session'], Session::class); } 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->documents = $documents; $this->options = $options; } /** * Execute the operation. * * @see Executable::execute() * @param Server $server * @return InsertManyResult * @throws DriverRuntimeException for other driver errors (e.g. connection errors) */ public function execute(Server $server) { $inTransaction = isset($this->options['session']) && $this->options['session']->isInTransaction(); if ($inTransaction && isset($this->options['writeConcern'])) { throw UnsupportedException::writeConcernNotSupportedInTransaction(); } $options = ['ordered' => $this->options['ordered']]; if ( ! empty($this->options['bypassDocumentValidation']) && server_supports_feature($server, self::$wireVersionForDocumentLevelValidation) ) { $options['bypassDocumentValidation'] = $this->options['bypassDocumentValidation']; } $bulk = new Bulk($options); $insertedIds = []; foreach ($this->documents as $i => $document) { $insertedIds[$i] = $bulk->insert($document); } $writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $this->createOptions()); return new InsertManyResult($writeResult, $insertedIds); } /** * Create options for executing the bulk write. * * @see http://php.net/manual/en/mongodb-driver-server.executebulkwrite.php * @return array */ private function createOptions() { $options = []; if (isset($this->options['session'])) { $options['session'] = $this->options['session']; } if (isset($this->options['writeConcern'])) { $options['writeConcern'] = $this->options['writeConcern']; } return $options; } }