2009-03-24 18:25:46 +00:00
<?xml version="1.0" encoding="utf-8"?>
2009-03-24 19:13:51 +00:00
<!-- $Revision: 1.3 $ -->
2009-03-24 18:25:46 +00:00
2009-03-24 19:05:50 +00:00
<refentry xml:id= "mongoid.construct" xmlns= "http://docbook.org/ns/docbook" xmlns:xlink= "http://www.w3.org/1999/xlink" >
2009-03-24 18:25:46 +00:00
<refnamediv >
2009-03-24 19:05:50 +00:00
<refname > MongoId::__construct</refname>
<refpurpose > Creates a new id</refpurpose>
2009-03-24 18:25:46 +00:00
</refnamediv>
<refsect1 role= "description" >
&reftitle.description;
<methodsynopsis >
2009-03-24 19:05:50 +00:00
<methodname > MongoId::__construct</methodname>
<methodparam choice= "opt" > <type > string</type> <parameter > id</parameter> <initializer > &null; </initializer> </methodparam>
2009-03-24 18:25:46 +00:00
</methodsynopsis>
</refsect1>
<refsect1 role= "parameters" >
&reftitle.parameters;
<para >
<variablelist >
<varlistentry >
<term >
2009-03-24 19:05:50 +00:00
<parameter > id</parameter>
2009-03-24 18:25:46 +00:00
</term>
<listitem >
<para >
2009-03-24 19:05:50 +00:00
A string to use as the id.
2009-03-24 18:25:46 +00:00
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role= "returnvalues" >
&reftitle.returnvalues;
<para >
2009-03-24 19:05:50 +00:00
Returns a new id.
2009-03-24 18:25:46 +00:00
</para>
</refsect1>
<refsect1 role= "examples" >
&reftitle.examples;
<example >
2009-03-24 19:05:50 +00:00
<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 hexidecimal 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" >
2009-03-24 18:25:46 +00:00
< ![CDATA[
< ?php
2009-03-24 19:05:50 +00:00
$id1 = new MongoId();
2009-03-24 18:25:46 +00:00
2009-03-24 19:05:50 +00:00
// create a new id from $id1
$id2 = new MongoId("$id1");
2009-03-24 18:25:46 +00:00
2009-03-24 19:05:50 +00:00
// show that $id1 and $id2 have the same hexidecimal value
var_dump($id1 == $id2);
?>
2009-03-24 18:25:46 +00:00
]]>
2009-03-24 19:05:50 +00:00
</programlisting>
&example.outputs.similar;
<screen >
2009-03-24 18:25:46 +00:00
< ![CDATA[
2009-03-24 19:05:50 +00:00
bool(true)
2009-03-24 18:25:46 +00:00
]]>
2009-03-24 19:05:50 +00:00
</screen>
2009-03-24 18:25:46 +00:00
</example>
</refsect1>
2009-03-24 19:05:50 +00:00
<refsect1 role= "seealso" >
&reftitle.seealso;
<para >
<simplelist >
<member > <methodname > MongoId::__toString</methodname> </member>
</simplelist>
</para>
</refsect1>
2009-03-24 18:25:46 +00:00
</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
-->