« MongoDB\BSON\Persistable
MongoDB\BSON\Serializable »

MongoDB\BSON\Persistable::bsonSerialize

(mongodb >=1.0.0)

MongoDB\BSON\Persistable::bsonSerialize — Provides an array or document to serialize as BSON

説明

abstract public function MongoDB\BSON\Persistable::bsonSerialize(): array|stdClass|MongoDB\BSON\Document

Called during serialization of the object to BSON. The method must return an array, stdClass, or MongoDB\BSON\Document.

The return value will always be serialized as a BSON document. The serialized document will include a field containing the class name of the object. For this reason, it is not possible to return a MongoDB\BSON\PackedArray instance in this method.

Users are encouraged to include an _id property (e.g. a MongoDB\BSON\ObjectId initialized in the constructor) when returning data for a BSON root document. In the absence of an _id property, the extension or server will generate a MongoDB\BSON\ObjectId for insert or upsert operations, respectively.

パラメータ

この関数にはパラメータはありません。

戻り値

An array, stdClass, or MongoDB\BSON\Document to be serialized as a BSON document.

変更履歴

バージョン 説明
PECL mongodb 2.0.0 Return types previously declared as tentative are now enforced.
PECL mongodb 1.17.0 This method may now also return MongoDB\BSON\Document instances in addition to array and stdClass.

参考

関連キーワード:
MongoDB   document   Persistable   Provides   serialize   bsonSerialize   stdClass   Document   return   mongodb   method   serialized   Serializable   property   ObjectId   abstract   Called   during   serialization   always   containing   reason   PackedArray   instance   Users
関連する関数・ページ:
class.mongodb-bson-persistable   mongodb-bson-serializable.bsonserialize   mongodb-bson-document.get   mongodb-bson-document.offsetget   class.mongodb-bson-serializable   mongodb-bson-document.has