php8.5
Home/ Manual/ bson / document/ MongoDB\BSON\Document::fromBSON

MongoDB\BSON\Document::fromBSON

PHP function Edit on GitHub ✎

(mongodb >=1.16.0)

Construct a new document instance from a BSON string

Description

MongoDB\BSON\Document::fromBSON(string $bson): MongoDB\BSON\Document

Parameters

bson (string)

A string containing a document in BSON format.

Return Values

Returns a new MongoDB\BSON\Document instance.

Errors/Exceptions

  • Throws MongoDB\Driver\Exception\UnexpectedValueException if bson is an invalid BSON string or contains more than a single document.

See Also

  • MongoDB\BSON\Document::fromPHP
  • MongoDB\BSON\Document::fromJSON
  • BSON Types

Source: reference/mongodb/bson/document/frombson.xml · from the official PHP manual (php/doc-en)