mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00

https://jira.mongodb.org/browse/PHPC-1004 git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@342971 c90b9560-bf6c-de11-be94-00142212c4b1
138 lines
4.2 KiB
XML
138 lines
4.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<phpdoc:classref xml:id="class.mongoid" 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 MongoId class</title>
|
|
<titleabbrev>MongoId</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
<warning>
|
|
&mongo.alternative.class.note;
|
|
<simplelist role="alternatives">
|
|
<member><classname>MongoDB\BSON\ObjectId</classname></member>
|
|
</simplelist>
|
|
</warning>
|
|
|
|
<!-- {{{ MongoId intro -->
|
|
<section xml:id="mongoid.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
A unique identifier created for database objects. If an object is inserted
|
|
into the database without an _id field, an _id field will be added to it
|
|
with a <classname>MongoId</classname> instance as its value. If the data
|
|
has a naturally occuring unique field (e.g. username or timestamp) it is
|
|
fine to use this as the _id field instead, and it will not be replaced with
|
|
a <classname>MongoId</classname>.
|
|
</para>
|
|
<para>
|
|
Instances of the <classname>MongoId</classname> class fulfill the role that
|
|
autoincrementing does in a relational database: to provide a unique key if
|
|
the data does not naturally have one. Autoincrementing does not work well
|
|
with a sharded database, as it is difficult to determine the next number in
|
|
the sequence. This class fulfills the constraints of quickly generating a
|
|
value that is unique across shards.
|
|
</para>
|
|
<para>
|
|
Each MongoId is 12 bytes (making its string form 24 hexadecimal characters).
|
|
The first four bytes are a timestamp, the next three are a hash of the
|
|
client machine's hostname, the next two are the two least significant bytes
|
|
of the process id running the script, and the last three bytes are an
|
|
incrementing value.
|
|
</para>
|
|
<para>
|
|
<classname>MongoId</classname>s are serializable/unserializable. Their
|
|
serialized form is similar to their string form:
|
|
<screen>
|
|
<![CDATA[
|
|
C:7:"MongoId":24:{4af9f23d8ead0e1d32000000}
|
|
]]>
|
|
</screen>
|
|
</para>
|
|
</section>
|
|
<!-- }}} -->
|
|
|
|
<section xml:id="mongoid.synopsis">
|
|
&reftitle.classsynopsis;
|
|
|
|
<!-- {{{ Synopsis -->
|
|
<classsynopsis>
|
|
<ooclass><classname>MongoId</classname></ooclass>
|
|
|
|
<!-- {{{ Class synopsis -->
|
|
<classsynopsisinfo>
|
|
<ooclass>
|
|
<classname>MongoId</classname>
|
|
</ooclass>
|
|
</classsynopsisinfo>
|
|
<!-- }}} -->
|
|
|
|
<fieldsynopsis>
|
|
<modifier>public</modifier>
|
|
<type>string</type>
|
|
<varname linkend="mongoid.props.id">$id</varname>
|
|
<initializer>&null;</initializer>
|
|
</fieldsynopsis>
|
|
|
|
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongoid')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
|
|
</classsynopsis>
|
|
<!-- }}} -->
|
|
|
|
</section>
|
|
|
|
<section>
|
|
<title>Fields</title>
|
|
<variablelist>
|
|
<varlistentry xml:id="mongoid.props.id">
|
|
<term><varname>$id</varname></term>
|
|
<listitem>
|
|
<simpara>
|
|
This field contains the string representation of this object.
|
|
</simpara>
|
|
<note>
|
|
<simpara>
|
|
The property name begins with a <literal>$</literal> character. It may
|
|
be accessed using
|
|
<link linkend="language.types.string.parsing.complex">complex variable
|
|
parsed syntax</link> (e.g. <literal>$mongoId->{'$id'}</literal>).
|
|
</simpara>
|
|
</note>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</section>
|
|
|
|
<section>
|
|
&reftitle.seealso;
|
|
<para>
|
|
MongoDB core docs on <link xlink:href="&url.mongodb.dochub.objectids;">ObjectIds</link>.
|
|
</para>
|
|
</section>
|
|
</partintro>
|
|
|
|
&reference.mongo.entities.mongoid;
|
|
|
|
</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
|
|
-->
|