class MongoId (View source)

A unique identifier created for database objects.

Properties

string $id

Methods

__construct(MongoId|string $id = null)

(PECL mongo >= 0.8.0) Creates a new id

static bool
isValid(mixed $value)

(PECL mongo >= 0.8.0) Check if a value is a valid ObjectId

string
__toString()

(PECL mongo >= 0.8.0) Returns a hexadecimal representation of this id

int
getInc()

(PECL mongo >= 1.0.11) Gets the incremented value to create this id

int
getPID()

(PECL mongo >= 1.0.11) Gets the process ID

int
getTimestamp()

(PECL mongo >= 1.0.1) Gets the number of seconds since the epoch that this id was created

static string
getHostname()

(PECL mongo >= 1.0.8) Gets the hostname being used for this machine's ids

static MongoId
__set_state(array $props)

(PECL mongo >= 1.0.8) Create a dummy MongoId

Details

__construct(MongoId|string $id = null)

(PECL mongo >= 0.8.0) Creates a new id

Parameters

MongoId|string $id

[optional] A string to use as the id. Must be 24 hexadecimal characters. If an invalid string is passed to this constructor, the constructor will ignore it and create a new id value.

static bool isValid(mixed $value)

(PECL mongo >= 0.8.0) Check if a value is a valid ObjectId

Parameters

mixed $value

The value to check for validity.

Return Value

bool

Returns TRUE if value is a MongoId instance or a string consisting of exactly 24 hexadecimal characters; otherwise, FALSE is returned.

string __toString()

(PECL mongo >= 0.8.0) Returns a hexadecimal representation of this id

Return Value

string

This id.

int getInc()

(PECL mongo >= 1.0.11) Gets the incremented value to create this id

Return Value

int

Returns the incremented value used to create this MongoId.

int getPID()

(PECL mongo >= 1.0.11) Gets the process ID

Return Value

int

Returns the PID of the MongoId.

int getTimestamp()

(PECL mongo >= 1.0.1) Gets the number of seconds since the epoch that this id was created

Return Value

int

static string getHostname()

(PECL mongo >= 1.0.8) Gets the hostname being used for this machine's ids

Return Value

string

Returns the hostname.

static MongoId __set_state(array $props)

(PECL mongo >= 1.0.8) Create a dummy MongoId

Parameters

array $props

Theoretically, an array of properties used to create the new id. However, as MongoId instances have no properties, this is not used.

Return Value

MongoId

A new id with the value "000000000000000000000000".