Phalcon\Db\Adapter\MongoDB\Operation\FindAndModify::__construct PHP Метод

__construct() публичный Метод

Supported options: * bypassDocumentValidation (boolean): If true, allows the write to opt out of document level validation. * fields (document): Limits the fields to return for the matching document. * maxTimeMS (integer): The maximum amount of time to allow the query to run. * new (boolean): When true, returns the modified document rather than the original. This option is ignored for remove operations. The The default is false. * query (document): Query by which to filter documents. * remove (boolean): When true, removes the matched document. This option cannot be true if the update option is set. The default is false. * sort (document): Determines which document the operation modifies if the query selects multiple documents. * update (document): Update or replacement to apply to the matched document. This option cannot be set if the remove option is true. * upsert (boolean): When true, a new document is created if no document matches the query. This option is ignored for remove operations. The default is false. * writeConcern (MongoDB\Driver\WriteConcern): Write concern. This option is only supported for server versions >= 3.2.
public __construct ( string $databaseName, string $collectionName, array $options )
$databaseName string Database name
$collectionName string Collection name
$options array Command options
    public function __construct($databaseName, $collectionName, array $options)
    {
        $options += ['new' => false, 'remove' => false, 'upsert' => false];
        if (isset($options['bypassDocumentValidation']) && !is_bool($options['bypassDocumentValidation'])) {
            throw InvalidArgumentException::invalidType('"bypassDocumentValidation" option', $options['bypassDocumentValidation'], 'boolean');
        }
        if (isset($options['fields']) && !is_array($options['fields']) && !is_object($options['fields'])) {
            throw InvalidArgumentException::invalidType('"fields" option', $options['fields'], 'array or object');
        }
        if (isset($options['maxTimeMS']) && !is_integer($options['maxTimeMS'])) {
            throw InvalidArgumentException::invalidType('"maxTimeMS" option', $options['maxTimeMS'], 'integer');
        }
        if (!is_bool($options['new'])) {
            throw InvalidArgumentException::invalidType('"new" option', $options['new'], 'boolean');
        }
        if (isset($options['query']) && !is_array($options['query']) && !is_object($options['query'])) {
            throw InvalidArgumentException::invalidType('"query" option', $options['query'], 'array or object');
        }
        if (!is_bool($options['remove'])) {
            throw InvalidArgumentException::invalidType('"remove" option', $options['remove'], 'boolean');
        }
        if (isset($options['sort']) && !is_array($options['sort']) && !is_object($options['sort'])) {
            throw InvalidArgumentException::invalidType('"sort" option', $options['sort'], 'array or object');
        }
        if (isset($options['update']) && !is_array($options['update']) && !is_object($options['update'])) {
            throw InvalidArgumentException::invalidType('"update" option', $options['update'], 'array or object');
        }
        if (isset($options['writeConcern']) && !$options['writeConcern'] instanceof WriteConcern) {
            throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], 'MongoDB\\Driver\\WriteConcern');
        }
        if (!is_bool($options['upsert'])) {
            throw InvalidArgumentException::invalidType('"upsert" option', $options['upsert'], 'boolean');
        }
        if (!(isset($options['update']) xor $options['remove'])) {
            throw new InvalidArgumentException('The "remove" option must be true or an "update" document must be specified, but not both');
        }
        $this->databaseName = (string) $databaseName;
        $this->collectionName = (string) $collectionName;
        $this->options = $options;
    }