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

<refentry xml:id="mongoid.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>MongoId::__construct</refname>
  <refpurpose>Creates a new id</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <methodname>MongoId::__construct</methodname>
   <methodparam choice="opt"><type>string</type><parameter>id</parameter><initializer>NULL</initializer></methodparam>
  </methodsynopsis>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term>
      <parameter>id</parameter>
     </term>
     <listitem>
      <para>
       A string to use as the id.
      </para>
     </listitem>
    </varlistentry>   
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns a new id.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title><function>MongoId::__construct</function> example</title>
   <para>This example shows how to create a new id. This is seldom necessary, as the driver adds an id to arrays automatically before storing them in the database.</para>
   <programlisting role="php">
<![CDATA[
<?php

  $id1 = new MongoId();
  echo "$id1\n";

  $id1 = new MongoId();
  echo "$id2\n";

  ?>
]]>
   </programlisting>
   &example.outputs.similar;
   <screen>
<![CDATA[
49a7011a05c677b9a916612a
49a702d5450046d3d515d10d
]]>
   </screen>
   <para>
    Note that the second hexadecimal number is greater than the first.
   </para>
  </example>
  <example>
   <title>Parameter example</title>
   <para>This example shows how to use a string parameter to initialize a MongoId with a given value.</para>
   <programlisting role="php">
<![CDATA[
<?php
  $id1 = new MongoId();

  // create a new id from $id1
  $id2 = new MongoId("$id1");

  // show that $id1 and $id2 have the same hexidecimal value
  var_dump($id1 == $id2);
  ?>
]]>
   </programlisting>
   &example.outputs.similar;
   <screen>
<![CDATA[
bool(true)
]]>
   </screen>
  </example>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><methodname>MongoId::__toString</methodname></member>
   </simplelist>
  </para>
 </refsect1>
</refentry>

<!-- 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:"../../../../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
-->