芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/cache/stores/mongodb/MongoDB/Operation/CreateCollection.php
isDefault()) { unset($options['writeConcern']); } if (isset($options['autoIndexId'])) { trigger_error('The "autoIndexId" option is deprecated and will be removed in a future release', E_USER_DEPRECATED); } $this->databaseName = (string) $databaseName; $this->collectionName = (string) $collectionName; $this->options = $options; } /** * Execute the operation. * * @see Executable::execute() * @param Server $server * @return array|object Command result document * @throws UnsupportedException if collation or write 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['writeConcern']) && ! \MongoDB\server_supports_feature($server, self::$wireVersionForWriteConcern)) { throw UnsupportedException::writeConcernNotSupported(); } $cursor = $server->executeWriteCommand($this->databaseName, $this->createCommand(), $this->createOptions()); if (isset($this->options['typeMap'])) { $cursor->setTypeMap($this->options['typeMap']); } return current($cursor->toArray()); } /** * Create the create command. * * @return Command */ private function createCommand() { $cmd = ['create' => $this->collectionName]; foreach (['autoIndexId', 'capped', 'flags', 'max', 'maxTimeMS', 'size', 'validationAction', 'validationLevel'] as $option) { if (isset($this->options[$option])) { $cmd[$option] = $this->options[$option]; } } foreach (['collation', 'indexOptionDefaults', 'storageEngine', 'validator'] as $option) { if (isset($this->options[$option])) { $cmd[$option] = (object) $this->options[$option]; } } return new Command($cmd); } /** * Create options for executing the command. * * @see http://php.net/manual/en/mongodb-driver-server.executewritecommand.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; } }