<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 330798 $ -->

<phpdoc:classref xml:id="class.mongobindata" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">

 <title>The MongoBinData class</title>
 <titleabbrev>MongoBinData</titleabbrev>

 <partintro>

<!-- {{{ MongoBinData intro -->
  <section xml:id="mongobindata.intro">
   &reftitle.intro;
   <para>
    An object that can be used to store or retrieve binary data from the database.
   </para>
   <para>
    The maximum size of a single object that can be inserted into the database
    is 16MB. For data that is larger than this (movies, music, Henry Kissinger's
    autobiography), use <classname>MongoGridFS</classname>. For data that is
    smaller than 16MB, you may find it easier to embed it within the document
    using <classname>MongoBinData</classname>.
   </para>
   <para>
    For example, to embed an image in a document, one could write:
   </para>
   <example xml:id="mongobindata.intro-example">
    <programlisting role="php">
<![CDATA[
<?php

$profile = array("username" => "foobity",
    "pic" => new MongoBinData(file_get_contents("gravatar.jpg"))
);

$users->save($profile);

?>
]]>
    </programlisting>
   </example>
   <para>
    This class contains a <varname>type</varname> field, which currently gives 
    no additional functionality in the driver or the database.  There are five 
    predefined types (which are the class constants listed below), and the user 
    can create their own (at the risk of the BSON spec catching up with them). 
    By default, the PHP driver always uses type 2: a byte array.
   </para>
  </section>
<!-- }}} -->

  <section xml:id="mongobindata.synopsis">
   &reftitle.classsynopsis;

<!-- {{{ Synopsis -->
   <classsynopsis>
    <ooclass><classname>MongoBinData</classname></ooclass>

<!-- {{{ Class synopsis -->
    <classsynopsisinfo>
     <ooclass>
      <classname>MongoBinData</classname>
     </ooclass>
    </classsynopsisinfo>
<!-- }}} -->
    
    <classsynopsisinfo role="comment">&Constants;</classsynopsisinfo>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongobindata.constants.func">MongoBinData::FUNC</varname>
     <initializer>1</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongobindata.constants.bytearray">MongoBinData::BYTE_ARRAY</varname>
     <initializer>2</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongobindata.constants.uuid">MongoBinData::UUID</varname>
     <initializer>3</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongobindata.constants.md5">MongoBinData::MD5</varname>
     <initializer>5</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongobindata.constants.custom">MongoBinData::CUSTOM</varname>
     <initializer>128</initializer>
    </fieldsynopsis>

    <classsynopsisinfo role="comment">Fields</classsynopsisinfo>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>string</type>
     <varname>bin</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>int</type>
     <varname>type</varname>
     <initializer>2</initializer>
    </fieldsynopsis>

    <classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
    <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongobindata')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
   </classsynopsis>
<!-- }}} -->

  </section>

<!-- {{{ MongoBinData constants -->
  <section>
   &reftitle.constants;
   <section xml:id="mongobindata.constants.types">
    <title>Binary Data Types</title>
    <variablelist>
     <varlistentry xml:id="mongobindata.constants.func">
      <term><constant>MongoBinData::FUNC</constant></term>
      <term><constant>0x01</constant></term>
      <listitem>
       <simpara>
        Function.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry xml:id="mongobindata.constants.bytearray">
      <term><constant>MongoBinData::BYTE_ARRAY</constant></term>
      <term><constant>0x02</constant></term>
      <listitem>
       <simpara>
        Array of bytes.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry xml:id="mongobindata.constants.uuid">
      <term><constant>MongoBinData::UUID</constant></term>
      <term><constant>0x03</constant></term>
      <listitem>
       <simpara>
        Universally unique identifier.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry xml:id="mongobindata.constants.md5">
      <term><constant>MongoBinData::MD5</constant></term>
      <term><constant>0x05</constant></term>
      <listitem>
       <simpara>
        MD5.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry xml:id="mongobindata.constants.custom">
      <term><constant>MongoBinData::CUSTOM</constant></term>
      <term><constant>0x80</constant></term>
      <listitem>
       <simpara>
        User-defined type.
       </simpara>
      </listitem>
     </varlistentry>
    </variablelist>
   </section>
  </section>
<!-- }}} -->

 </partintro>

 &reference.mongo.entities.mongobindata;

</phpdoc:classref>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
