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

<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"), MongoBinData::GENERIC),
);

$users->save($profile);

?>
]]>
    </programlisting>
   </example>
   <para>
    This class contains a <varname>type</varname> field, which currently gives
    no additional functionality in the PHP driver or the database. There are
    seven predefined types, which are defined as class constants below. For
    backwards compatibility, the PHP driver uses
    <constant>MongoBinData::BYTE_ARRAY</constant> as the default; however, this
    may change to <constant>MongoBinData::GENERIC</constant> in the future.
    Users are encouraged to specify a type in
    <function>MongoBinData::__construct</function>.
   </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.generic">MongoBinData::GENERIC</varname>
     <initializer>0</initializer>
    </fieldsynopsis>
    <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.byte_array">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.uuid_rfc4122">MongoBinData::UUID_RFC4122</varname>
     <initializer>4</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.generic">
      <term><constant>MongoBinData::GENERIC</constant></term>
      <term><constant>0x00</constant></term>
      <listitem>
       <simpara>
        Generic binary data.
       </simpara>
      </listitem>
     </varlistentry>
     <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.byte_array">
      <term><constant>MongoBinData::BYTE_ARRAY</constant></term>
      <term><constant>0x02</constant></term>
      <listitem>
       <simpara>
        Generic binary data (deprecated in favor of
        <constant>MongoBinData::GENERIC</constant>).
       </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 (deprecated in favor of
        <constant>MongoBinData::UUID_RFC4122</constant>).
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry xml:id="mongobindata.constants.uuid_rfc4122">
      <term><constant>MongoBinData::UUID_RFC4122</constant></term>
      <term><constant>0x04</constant></term>
      <listitem>
       <simpara>
        Universally unique identifier (according to
        <link xlink:href="&url.rfc;4122">RFC 4122</link>).
       </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>
<!-- }}} -->

  <simplesect role="changelog">
   &reftitle.changelog;
   <informaltable>
    <tgroup cols="2">
     <thead>
      <row>
       <entry>&Version;</entry>
       <entry>&Description;</entry>
      </row>
     </thead>
     <tbody>
      <row>
       <entry>1.5.0</entry>
       <entry>
        Added <constant>MongoBinData::GENERIC</constant> and
        <constant>MongoBinData::UUID_RFC4122</constant> constants.
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </simplesect>

 </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
-->
