(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)要執行的命令。
options
| 選項 | 類型 | 描述 |
|---|---|---|
| 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。 |