2015-03-24 18:15:02 +00:00
<?xml version="1.0" encoding="utf-8"?>
2015-03-30 12:56:33 +00:00
<!-- $Revision$ -->
2015-03-24 18:15:02 +00:00
2015-09-23 15:35:13 +00:00
<refentry xml:id= "mongodb-bson-objectid.construct" xmlns= "http://docbook.org/ns/docbook" xmlns:xlink= "http://www.w3.org/1999/xlink" >
2015-03-24 18:15:02 +00:00
<refnamediv >
2017-08-30 16:05:54 +00:00
<refname > MongoDB\BSON\ObjectId::__construct</refname>
<refpurpose > Construct a new ObjectId</refpurpose>
2015-03-24 18:15:02 +00:00
</refnamediv>
<refsect1 role= "description" >
&reftitle.description;
<methodsynopsis >
2017-08-30 16:05:54 +00:00
<modifier > final</modifier> <modifier > public</modifier> <methodname > MongoDB\BSON\ObjectId::__construct</methodname>
2015-03-24 18:15:02 +00:00
<methodparam choice= "opt" > <type > string</type> <parameter > id</parameter> </methodparam>
</methodsynopsis>
</refsect1>
<refsect1 role= "parameters" >
&reftitle.parameters;
<variablelist >
<varlistentry >
2015-12-17 21:57:19 +00:00
<term > <parameter > id</parameter> (<type > string</type> )</term>
2015-03-24 18:15:02 +00:00
<listitem >
<para >
2015-12-17 21:57:19 +00:00
A 24-character hexadecimal string. If not provided, the driver will
2017-08-30 16:05:54 +00:00
generate an ObjectId.
2015-03-24 18:15:02 +00:00
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role= "errors" >
&reftitle.errors;
2015-12-17 21:57:19 +00:00
<simplelist >
&mongodb.throws.argumentparsing;
<member > Throws <classname > MongoDB\Driver\Exception\InvalidArgumentException</classname> if <parameter > id</parameter> is not a 24-character hexadecimal string.</member>
</simplelist>
2015-03-24 18:15:02 +00:00
</refsect1>
<refsect1 role= "examples" >
&reftitle.examples;
<example >
2017-08-30 16:05:54 +00:00
<title > <function > MongoDB\BSON\ObjectId::__construct</function> example</title>
2015-03-24 18:15:02 +00:00
<programlisting role= "php" >
< ![CDATA[
< ?php
2017-08-30 16:05:54 +00:00
var_dump(new MongoDB\BSON\ObjectId());
2015-12-17 21:57:19 +00:00
2017-08-30 16:05:54 +00:00
var_dump(new MongoDB\BSON\ObjectId('000000000000000000000001'));
2015-03-24 18:15:02 +00:00
?>
]]>
</programlisting>
&example.outputs.similar;
<screen >
< ![CDATA[
2017-08-30 16:05:54 +00:00
object(MongoDB\BSON\ObjectId)#1 (1) {
2015-12-17 21:57:19 +00:00
["oid"]=>
string(24) "56732d3dda14d81214634921"
}
2017-08-30 16:05:54 +00:00
object(MongoDB\BSON\ObjectId)#1 (1) {
2015-12-17 21:57:19 +00:00
["oid"]=>
string(24) "000000000000000000000001"
}
2015-03-24 18:15:02 +00:00
]]>
</screen>
</example>
</refsect1>
<refsect1 role= "seealso" >
&reftitle.seealso;
<simplelist >
2017-08-30 16:05:54 +00:00
<member > <link xlink:href= "&url.mongodb.docs.objectid;" > ObjectId Reference</link> </member>
<member > <link xlink:href= "&url.mongodb.docs.bson;#objectid" > BSON Types: ObjectId</link> </member>
2015-03-24 18:15:02 +00:00
</simplelist>
</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:"~/.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
-->