update : 2015.11.03
php.shukuma.com검색:
|
MongoDB\BSON\Serializable::bsonSerialize(mongodb >=1.0.0) MongoDB\BSON\Serializable::bsonSerialize — Provides an array or document to serialize as BSON 설명
abstract public array|object MongoDB\BSON\Serializable::bsonSerialize
( void
)
Called during serialization of the object to BSON. The method must return an array or stdClass. Root documents (e.g. a MongoDB\BSON\Serializable passed to MongoDB\BSON\fromPHP()) will always be serialized as a BSON document. For field values, associative arrays and stdClass instances will be serialized as a BSON document and sequential arrays (i.e. sequential, numeric indexes starting at 0) will be serialized as a BSON array. 인수이 함수는 인수가 없습니다. 반환값An array or stdClass to be serialized as a BSON array or document. 예제Example #1 MongoDB\BSON\Serializable::bsonSerialize() returning an associative array for root document
<?php 위 예제의 출력: { "foo" : "bar" } Example #2 MongoDB\BSON\Serializable::bsonSerialize() returning a sequential array for root document
<?php 위 예제의 출력: { "0" : 1, "1" : 2, "2" : 3 } Example #3 MongoDB\BSON\Serializable::bsonSerialize() returning an associative array for document field
<?php 위 예제의 출력: { "document" : { "foo" : "bar" } } Example #4 MongoDB\BSON\Serializable::bsonSerialize() returning a sequential array for document field
<?php 위 예제의 출력: { "array" : [ 1, 2, 3 ] } 참고
|