大网数据广告活动
PHP 语言与运行手册

The MongoDB\Driver\Monitoring\CommandFailedEvent class

· 52CE 我爱测

The MongoDB\Driver\Monitoring\CommandFailedEvent class encapsulates information about a failed command.

The MongoDB\Driver\Monitoring\CommandFailedEvent class

(mongodb >=1.3.0)

Introduction

The MongoDB\Driver\Monitoring\CommandFailedEvent class encapsulates information about a failed command.

Class synopsis

final class MongoDB\Driver\Monitoring\CommandFailedEvent {
/* Properties */
public readonly string $host;
public readonly int $port;
public readonly string $commandName;
public readonly string $databaseName;
public readonly int $duration;
public readonly Exception $error;
public readonly object $reply;
public readonly string $operationId;
public readonly string $requestId;
public readonly ?int $serverConnectionId;
/* Methods */
final public function getCommandName(): string
final public function getDatabaseName(): string
final public function getDurationMicros(): int
final public function getError(): Exception
final public function getHost(): string
final public function getOperationId(): string
final public function getPort(): int
final public function getReply(): object
final public function getRequestId(): string
final public function getServer(): MongoDB\Driver\Server
final public function getServerConnectionId(): ?int
final public function getServiceId(): ?MongoDB\BSON\ObjectId
}

Properties

host

The hostname of the server that executed the command.

port

The port of the server that executed the command.

commandName

The command name.

databaseName

The database name.

duration

The duration of the command in microseconds. The duration is a calculated value that includes the time to send the message and receive the response from the server.

error

The exception that was thrown when the command failed.

reply

The failure reply document returned by the server.

operationId

The operation ID. This may be used to link events together such as bulk writes, which may dispatch multiple commands.

requestId

The request ID. This may be used to associate this MongoDB\Driver\Monitoring\CommandFailedEvent with a corresponding MongoDB\Driver\Monitoring\CommandStartedEvent.

serviceId

The service ID, or null if the server does not support it (i.e. not using load-balanced mode).

serverConnectionId

The server connection ID, or null if not available.

Changelog

Version Description
PECL mongodb 2.3.0 Added public readonly properties. The duration property replaces the getDurationMicros() method.

Table of Contents

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。