<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/mongodb.bson.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'class.mongodb-bson-persistable.php',
    1 => 'MongoDB\\BSON\\Persistable',
    2 => 'The MongoDB\\BSON\\Persistable interface',
  ),
  'up' => 
  array (
    0 => 'mongodb.bson.php',
    1 => 'MongoDB\\BSON',
  ),
  'prev' => 
  array (
    0 => 'class.mongodb-bson-type.php',
    1 => 'MongoDB\\BSON\\Type',
  ),
  'next' => 
  array (
    0 => 'mongodb-bson-persistable.bsonserialize.php',
    1 => 'MongoDB\\BSON\\Persistable::bsonSerialize',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mongodb/bson/persistable.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/class.mongodb-bson-persistable.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="class.mongodb-bson-persistable" class="reference">

 <h1 class="title">The MongoDB\BSON\Persistable interface</h1>
 

 <div class="partintro"><p class="verinfo">(mongodb &gt;=1.0.0)</p>


  <div class="section" id="mongodb-bson-persistable.intro">
   <h2 class="title">简介</h2>
   <p class="simpara">
    Classes may implement this interface to take advantage of automatic ODM
    (object document mapping) behavior in the extension. During serialization,
    the extension will inject a <span class="property">__pclass</span> property
    containing the PHP class name into the data returned by
    <span class="function"><a href="mongodb-bson-serializable.bsonserialize.php" class="function">MongoDB\BSON\Serializable::bsonSerialize()</a></span>. During
    unserialization, the same <span class="property">__pclass</span> property will then
    be used to infer the PHP class (independent of any
    <a href="mongodb.persistence.php#mongodb.persistence.typemaps" class="link">type map</a> configuration)
    to be constructed before
    <span class="function"><a href="mongodb-bson-unserializable.bsonunserialize.php" class="function">MongoDB\BSON\Unserializable::bsonUnserialize()</a></span> is
    invoked. See <a href="mongodb.persistence.php" class="xref">Persisting Data</a> for additional
    information.
   </p>
   <blockquote class="note"><p><strong class="note">注意</strong>: 
    <span class="simpara">
     Even if <span class="function"><a href="mongodb-bson-serializable.bsonserialize.php" class="function">MongoDB\BSON\Serializable::bsonSerialize()</a></span> would
     return a sequential array, injection of the <span class="property">__pclass</span>
     property will cause the object to be serialized as a BSON document.
    </span>
   </p></blockquote>
  </div>


  <div class="section" id="mongodb-bson-persistable.synopsis">
   <h2 class="title">接口摘要</h2>


   <div class="classsynopsis">
    <span class="ooclass"><strong class="classname"></strong></span>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">MongoDB\BSON\Persistable</strong>
     </span>

     <span class="oointerface"><span class="modifier">implements</span> 
       <a href="class.mongodb-bson-unserializable.php" class="interfacename">MongoDB\BSON\Unserializable</a></span><span class="oointerface">,  <a href="class.mongodb-bson-serializable.php" class="interfacename">MongoDB\BSON\Serializable</a></span> {</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">abstract</span> <span class="modifier">public</span> <span class="methodname"><a href="mongodb-bson-persistable.bsonserialize.php" class="methodname">bsonSerialize</a></span>(): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="class.stdclass.php" class="type stdClass">stdClass</a></span>|<span class="type"><a href="class.mongodb-bson-document.php" class="type MongoDB\BSON\Document">MongoDB\BSON\Document</a></span></span></div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的方法 */</div>
    <div class="methodsynopsis dc-description"><span class="modifier">abstract</span> <span class="modifier">public</span> <span class="methodname"><a href="mongodb-bson-serializable.bsonserialize.php" class="methodname">MongoDB\BSON\Serializable::bsonSerialize</a></span>(): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="class.stdclass.php" class="type stdClass">stdClass</a></span>|<span class="type"><a href="class.mongodb-bson-document.php" class="type MongoDB\BSON\Document">MongoDB\BSON\Document</a></span>|<span class="type"><a href="class.mongodb-bson-packedarray.php" class="type MongoDB\BSON\PackedArray">MongoDB\BSON\PackedArray</a></span></span></div>

    <div class="methodsynopsis dc-description"><span class="modifier">abstract</span> <span class="modifier">public</span> <span class="methodname"><a href="mongodb-bson-unserializable.bsonunserialize.php" class="methodname">MongoDB\BSON\Unserializable::bsonUnserialize</a></span>(<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$data</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

   }</div>


  </div>

 </div>

 







<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="mongodb-bson-persistable.bsonserialize.php">MongoDB\BSON\Persistable::bsonSerialize</a> — Provides an array or document to serialize as BSON</li></ul>
</div>
<?php manual_footer($setup); ?>