MongoDB\BSON\ObjectID::__construct

(mongodb >=1.0.0)

MongoDB\BSON\ObjectID::__constructConstruct a new ObjectID

설명

final public MongoDB\BSON\ObjectID::__construct ([ string $id ] )

인수

id (string)

A 24-character hexadecimal string. If not provided, the driver will generate an ObjectID.

오류/예외

예제

Example #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"
}

add a note add a note

User Contributed Notes 1 note

up
3
fejlesztes at letscode dot hu
6 years ago
If you pass NULL to the __construct() method, it wont throw exceptions, nor errors, but prematurely ends the PHP processing (so it produced an 502 response over nginx), not like the legacy MongoId class.
To Top