(mongodb >=1.4.0)
MongoDB\Driver\Manager::executeWriteCommand — 执行写入数据库命令
$db, MongoDB\Driver\Command $command, ?array $options = null): MongoDB\Driver\Cursor在主服务器上执行命令。
此方法将应用特定于写入命令的逻辑(例如 » drop)。"writeConcern" 选项的默认值将从活动事务(由 "session" 选项指示)推断,然后从 连接 URI 推断。
注意: 此方法并非旨在用于执行 » insert、» update 或 » delete 命令。鼓励用户使用 MongoDB\Driver\Manager::executeBulkWrite() 执行这些操作。
db (string)要执行命令的数据库名称。
command (MongoDB\Driver\Command)要执行的命令。
选项
| 选项 | 类型 | 描述 |
|---|---|---|
| session | MongoDB\Driver\Session |
要与操作关联的会话。 |
| writeConcern | MongoDB\Driver\WriteConcern |
要应用于操作的写入关注。 |
如果您正在使用具有正在进行的事务的 "session",则不能指定 "readConcern" 或 "writeConcern" 选项。这将导致抛出 MongoDB\Driver\Exception\InvalidArgumentException。相反,您应该在使用 MongoDB\Driver\Session::startTransaction() 创建事务时设置这两个选项。
成功时返回 MongoDB\Driver\Cursor。
"session" 选项与关联的事务结合使用以及 "readConcern" 或 "writeConcern" 选项,则抛出 MongoDB\Driver\Exception\InvalidArgumentException。"session" 选项与未确认的写入关注结合使用,则抛出 MongoDB\Driver\Exception\InvalidArgumentException。
| 版本 | 描述 |
|---|---|
| PECL mongodb 1.4.4 |
如果 "session" 选项与未确认的写入关注结合使用,则将抛出 MongoDB\Driver\Exception\InvalidArgumentException。 |