MongoDB\BSON\ObjectId::__construct

(mongodb >=1.0.0)

MongoDB\BSON\ObjectId::__constructConstruct a new ObjectId

Descrierea

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

Parametri

id (string)

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

Erori/Excepții

Exemple

Example #1 MongoDB\BSON\ObjectId::__construct() example

<?php

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

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

?>

Exemplul de mai sus va afișa ceva similar cu:

object(MongoDB\BSON\ObjectId)#1 (1) {
  ["oid"]=>
  string(24) "56732d3dda14d81214634921"
}
object(MongoDB\BSON\ObjectId)#1 (1) {
  ["oid"]=>
  string(24) "000000000000000000000001"
}