PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

MongoDB\Driver\Cursor::setTypeMap - Sets a type map to use for BSON unserialization | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

MongoDB\Driver\Cursor::setTypeMap

(mongodb >=1.0.0)

MongoDB\Driver\Cursor::setTypeMapSets a type map to use for BSON unserialization

説明

final public void MongoDB\Driver\Cursor::setTypeMap ( array $typemap )

Sets the type map configuration to use when unserializing the BSON results into PHP values.

パラメータ

typeMap (array)

型マップの設定

返り値

値を返しません。

エラー / 例外

例1 MongoDB\Driver\Cursor::setTypeMap() example

<?php

$manager 
= new MongoDB\Driver\Manager("mongodb://localhost:27017");

$bulk = new MongoDB\Driver\BulkWrite;
$id $bulk->insert(['x' => 1]);
$manager->executeBulkWrite('db.collection'$bulk);

$query = new MongoDB\Driver\Query(['_id' => $id]);
$cursor $manager->executeQuery('db.collection'$query);
$cursor->setTypeMap(['root' => 'array']);

foreach (
$cursor as $document) {
    
var_dump($document);
}

?>

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

array(2) {
  ["_id"]=>
  object(MongoDB\BSON\ObjectId)#6 (1) {
    ["oid"]=>
    string(24) "56424fb76118fd3267180741"
  }
  ["x"]=>
  int(1)
}

忘却曲線を使ってこの知識を確実に記憶に残す

フォーラムで「MongoDB\Driver\Cursor::setTypeMap - Sets a type map to use for BSON unserialization」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | MongoDB\Driver\Cursor::setTypeMap - Sets a type map to use for BSON unserialization」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: