芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/public_html/cepali/cache/stores/mongodb/MongoDB/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'], 'MongoDB\Driver\Session'); } if (isset($options['writeConcern']) && ! $options['writeConcern'] instanceof WriteConcern) { throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], 'MongoDB\Driver\WriteConcern'); } 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) { $options = ['ordered' => $this->options['ordered']]; if (isset($this->options['bypassDocumentValidation']) && \MongoDB\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; } }