(PECL mongo >=0.8.0)
警告 このクラスを定義している拡張モジュールは非推奨です。 かわりに MongoDB 拡張モジュールを使うべきです。 このクラスの代替として、以下が使えます。
はじめに
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 MongoId 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 MongoId.
Instances of the MongoId 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.
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.
MongoIds are serializable/unserializable. Their serialized form is similar to their string form:
C:7:"MongoId":24:{4af9f23d8ead0e1d32000000}
クラス概要
MongoId {
public
string
$$id
= null
public __construct
([ string|MongoId $id
= null
] )
public static getHostname ( ) : string
public getInc ( ) : int
public getPID ( ) : int
public getTimestamp ( ) : int
public static __set_state
( array $props
) : MongoId
public __toString ( ) : string
}
Fields
$id
This field contains the string representation of this object.
注意:
The property name begins with a
$
character. It may be accessed using complex variable parsed syntax (e.g.$mongoId->{'$id'}
).
目次
- MongoId::__construct — Creates a new id
- MongoId::getHostname — このマシンの id に使うホスト名を取得する
- MongoId::getInc — この id を作るためにインクリメントされた値を取得する
- MongoId::getPID — プロセス ID を取得する
- MongoId::getTimestamp — この id が作られたときのエポックからの経過秒数を取得する
- MongoId::isValid — Check if a value is a valid ObjectId
- MongoId::__set_state — ダミー MongoId を作成する
- MongoId::__toString — Returns a hexidecimal representation of this id
/* メソッド */