略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: MongoDB\BSON\Persistable

2024-12-20

The MongoDB\BSON\Persistable interface

(mongodb >=1.0.0)

简介

Classes may implement this interface to take advantage of automatic ODM (object document mapping) behavior in the driver. During serialization, the driver will inject a __pclass property containing the PHP class name into the data returned by MongoDB\BSON\Serializable::bsonSerialize(). During unserialization, the same __pclass property will then be used to infer the PHP class (independent of any type map configuration) to be constructed before MongoDB\BSON\Unserializable::bsonUnserialize() is invoked. See Persisting Data for additional information.

注意: Even if MongoDB\BSON\Serializable::bsonSerialize() would return a sequential array, injection of the __pclass property will cause the object to be serialized as a BSON document.

接口摘要

class MongoDB\BSON\Persistable implements MongoDB\BSON\Unserializable, MongoDB\BSON\Serializable {
/* 继承的方法 */
abstract public MongoDB\BSON\Serializable::bsonSerialize(): array|object
abstract public MongoDB\BSON\Unserializable::bsonUnserialize(array $data): void
}
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/class.mongodb-bson-persistable.php

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