« MongoDB\BSON\DBPointer::__toString
MongoDB\BSON\Int64::__construct »

The MongoDB\BSON\Int64 class

(mongodb >=1.5.0)

はじめに

BSON type for a 64-bit integer. When decoding BSON to PHP data, this class is used when a 64-bit integer cannot be represented as a PHP integer on 32-bit platforms. These objects support overloaded arithmetic, bitwise, and comparison operators.

When working with raw BSON data through the MongoDB\BSON\Document, MongoDB\BSON\PackedArray, and MongoDB\BSON\Iterator classes, any 64-bit integer will be returned as an instance of this class, regardless of platform and whether the value can be represented as a PHP integer. This ensures that values can be roundtripped without changing the type.

During BSON encoding, objects of this class will convert back to a 64-bit integer type, even when the value would fit in a 32-bit integer. This allows explicitly storing values as 64-bit integers in BSON.

クラス概要

final class MongoDB\BSON\Int64 implements MongoDB\BSON\Type, JsonSerializable, Stringable {
/* メソッド */
final public function __construct(int|string $value)
final public function jsonSerialize(): mixed
final public function __toString(): string
}

変更履歴

バージョン 説明
PECL mongodb 2.0.0 This class no longer implements the Serializable interface.
PECL mongodb 1.16.0 The class can now be instantiated on all platforms. Added support for overloaded arithmetic, bitwise, and comparison operators.
PECL mongodb 1.12.0 Implements Stringable for PHP 8.0+.

目次

関連キーワード:
MongoDB   integer   mongodb   final   toString   construct   type   represented   platforms   objects   support   overloaded   arithmetic   bitwise   comparison   operators   values   implements   Stringable   jsonSerialize   representation   DBPointer   decoding   used   cannot
関連する関数・ページ:
mongodb-bson-int64.construct   mongodb-bson-int64.tostring   class.mongodb-bson-dbpointer   mongodb-bson-int64.jsonserialize   class.mongodb-bson-utcdatetime   class.mongodb-bson-regex