略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: MongoDB\Driver\WriteResult::isAcknowledged

2024-11-13

MongoDB\Driver\WriteResult::isAcknowledged

(mongodb >=1.0.0)

MongoDB\Driver\WriteResult::isAcknowledgedReturns whether the write was acknowledged

说明

final public MongoDB\Driver\WriteResult::isAcknowledged(): bool

If the write is acknowledged, other count fields will be available on the MongoDB\Driver\WriteResult object.

参数

此函数没有参数。

返回值

Returns true if the write was acknowledged, and false otherwise.

错误/异常

范例

示例 #1 MongoDB\Driver\WriteResult::isAcknowledged() with acknowledged write concern

<?php

$manager 
= new MongoDB\Driver\Manager;

$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);

$result $manager->executeBulkWrite('db.collection'$bulk);

var_dump($result->isAcknowledged());

?>

以上例程会输出:

bool(true)

示例 #2 MongoDB\Driver\WriteResult::isAcknowledged() with unacknowledged write concern

<?php

$manager 
= new MongoDB\Driver\Manager;

$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);

$result $manager->executeBulkWrite('db.collection'$bulk, new MongoDB\Driver\WriteConcern(0));

var_dump($result->isAcknowledged());

?>

以上例程会输出:

bool(false)
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/mongodb-driver-writeresult.isacknowledged.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3