MongoDB\BSON\ObjectId::__construct
(mongodb >=1.0.0)
MongoDB\BSON\ObjectId::__construct — Construct a new ObjectId
パラメータ
id
(string)-
A 24-character hexadecimal string. If not provided, the extension will generate an ObjectId.
エラー / 例外
- Throws MongoDB\Driver\Exception\InvalidArgumentException on argument parsing errors.
- Throws MongoDB\Driver\Exception\InvalidArgumentException if
id
is not a 24-character hexadecimal string.
例
例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
User Contributed Notes 1 note
fejlesztes at letscode dot hu ¶
8 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.
↑ and ↓ to navigate •
Enter to select •
Esc to close
Press Enter without
selection to search using Google