MongoDB\Driver\Manager::startSession

(mongodb >=1.4.0)

MongoDB\Driver\Manager::startSessionStart a new client session for use with this client

Descripción

final public MongoDB\Driver\Manager::startSession ([ array $options ] ) : MongoDB\Driver\Session

Creates a MongoDB\Driver\Session for the given options. The session may then be specified when executing commands, queries, and write operations.

Nota: A MongoDB\Driver\Session can only be used with the MongoDB\Driver\Manager from which it was created.

Parámetros

options

options
Option Type Description Default
causalConsistency boolean

Configure causal consistency in a session. If TRUE, each operation in the session will be causally ordered after the previous read or write operation. Set to FALSE to disable causal consistency.

See » Casual Consistency in the MongoDB manual for more information.

TRUE
defaultTransactionOptions array

Default options to apply to newly created transactions. These options are used unless they are overridden when a transaction is started with different value for each option.

options
Option Type Description
maxCommitTimeMS integer

The maximum amount of time in milliseconds to allow a single commitTransaction command to run.

If specified, maxCommitTimeMS must be a signed 32-bit integer greater than or equal to zero.

readConcern MongoDB\Driver\ReadConcern

Un asunto de escritura a aplicar a la operación.

Esta opción está disponible en MongoDB 3.2+ y resultará en una excepción en tiempo de ejecución si es especificada para una versión de servidor más antigua.

readPreference MongoDB\Driver\ReadPreference

Una preferencia de lectura a usar para seleccionar un servidor para la operación.

writeConcern MongoDB\Driver\WriteConcern

Un asunto de escritura a aplicar a la operación.

This option is available in MongoDB 4.0+.

[]

Valores devueltos

Returns a MongoDB\Driver\Session.

Errores/Excepciones

Historial de cambios

Versión Descripción
1.6.0

The "maxCommitTimeMS" option was added to "defaultTransactionOptions".

1.5.0

The "defaultTransactionOptions" option was added.

Ver también