The MongoDB\BSON\ObjectId class

(mongodb >=1.0.0)

Einführung

BSON type for an » ObjectId. The value consists of 12 bytes, where the first four bytes are a timestamp that reflect the ObjectId's creation. Specifically, the value consists of:

  • a 4-byte value representing the seconds since the Unix epoch,
  • a 5-byte random number unique to a machine and process, and
  • a 3-byte counter, starting with a random value.

In MongoDB, each document stored in a collection requires a unique _id field that acts as a primary key. If an inserted document omits the _id field, the driver automatically generates an ObjectId for the _id field.

Using ObjectIds for the _id field provides the following additional benefits:

  • The creation time of the ObjectId may be accessed using the MongoDB\BSON\ObjectId::getTimestamp() method.
  • Sorting on an _id field that stores ObjectId values is roughly equivalent to sorting by creation time.

Klassenbeschreibung

/* Methoden */
final public __construct(string $id = ?)
final public getTimestamp(): int
final public jsonSerialize(): mixed
final public serialize(): string
final public __toString(): string
final public unserialize(string $serialized): void
}

Changelog

Version Beschreibung
PECL mongodb 1.12.0 Implements Stringable for PHP 8.0+.
PECL mongodb 1.3.0

Renamed from MongoDB\BSON\ObjectID to MongoDB\BSON\ObjectId.

Implements MongoDB\BSON\ObjectIdInterface.

PECL mongodb 1.2.0 Implements Serializable and JsonSerializable.

Inhaltsverzeichnis

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

rednisolona Precio. prednisolona con receta medica - como conseguir receita predniso

Precio prednisolona. prednisolona con receta medica ¿Busca medicamentos de primera calidad sin salir de casa? ¡No busque más! Nuestra tienda en ...

Geschrieben von travelder am 20.06.2026 16:02:20
Forum: Entwicklungsumgebungen
hampix Medicin. Mastercard online køb Champix - bestilling Champix. Hvidovre — Danma

Medicin Champix. Mastercard online køb Champix Leder du efter førsteklasses medicin uden at forlade hjemmet? Stop med at lede! Vores pålidelige ...

Geschrieben von drawer am 20.06.2026 16:01:53
Forum: Netzwerk & Internet
cetaminophen Prix. Acetaminophen Sans Prescription Us - Acheter Acetaminophen. Nîmes

Prix Acetaminophen. Acetaminophen Sans Prescription Us Avez besoin de médicaments de haute qualité ? Nous sommes là pour vous ! Notre pharmacie ...

Geschrieben von drawer am 20.06.2026 16:01:15
Forum: IT-Security
zempic tabletas. donde comprar Ozempic en concepcion - comprar Ozempic 2mg mercado l

tabletas Ozempic. donde comprar Ozempic en concepcion ¿Busca medicamentos de primera calidad sin salir de casa? ¡No busque más! Nuestra tienda ...

Geschrieben von travelder am 20.06.2026 16:00:46
Forum: Entwicklungsumgebungen