Php/docs/mongoid.tostring

提供:Dev Guides
< Php
移動先:案内検索

MongoId::__toString

(PECL mongo >= 0.8.0)

MongoId::__toStringReturns a hexidecimal representation of this id


このメソッドを定義している拡張モジュールは非推奨です。

かわりに MongoDB 拡張モジュールを使うべきです。 このメソッドの代替として、以下が使えます。

説明

public MongoId::__toString ( ) : string

パラメータ

この関数にはパラメータはありません。


返り値

This id.


例1 MongoId::__toString() example

<?php$m = new MongoClient();$collection = $m->selectDB("foo")->selectCollection("bar");$collection->insert(array( "x" => "y" ));$collection->insert(array( "x" => "y" ));$cursor = $collection->find();$r1 = $cursor->next();$r2 = $cursor->next();echo $r1["_id"] . "\n";echo $r2["_id"] . "\n";?>

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


49a7011a05c677b9a916612a
49a702d5450046d3d515d10d