« MongoDB\BSON\ObjectId
MongoDB\BSON\ObjectId::getTimestamp »

MongoDB\BSON\ObjectId::__construct

(mongodb >=1.0.0)

MongoDB\BSON\ObjectId::__construct — Construct a new ObjectId

説明

final public function MongoDB\BSON\ObjectId::__construct(?string $id = null)

パラメータ

id (string)

A 24-character hexadecimal string. If not provided, the extension will generate an ObjectId.

エラー / 例外

例

例1 MongoDB\BSON\ObjectId::__construct() example

<?php

var_dump(new MongoDB\BSON\ObjectId());

var_dump(new MongoDB\BSON\ObjectId('000000000000000000000001'));

?>

上の例の出力は、 たとえば以下のようになります。

object(MongoDB\BSON\ObjectId)#1 (1) {
  ["oid"]=>
  string(24) "56732d3dda14d81214634921"
}
object(MongoDB\BSON\ObjectId)#1 (1) {
  ["oid"]=>
  string(24) "000000000000000000000001"
}
関連キーワード:
ObjectId   MongoDB   construct   Construct   character   hexadecimal   Throws   Driver   Exception   InvalidArgumentException   dump   getTimestamp   mongodb   final   provided   extension   generate   argument   parsing   errors   example   参考   Reference   Types
関連する関数・ページ:
mongodb-bson-objectid.tostring   mongodb-bson-objectid.gettimestamp   class.mongodb-bson-objectid   mongodb-bson-objectid.jsonserialize   mongodb-bson-int64.construct   mongodb-driver-bulkwrite.insert