文字

MongoDBRef::get

(PECL mongo >= 0.9.0)

MongoDBRef::get获取引用所指向的对象

说明

public static array MongoDBRef::get ( MongoDB $db , array $ref )

参数

db

使用的数据库。

ref

要获取的引用。

返回值

返回引用指向的文档,如果文档不存在则返回 NULL (该引用已损坏)。

范例

Example #1 MongoCollection::createDBRef() 例子

<?php

// 从 db 获取 $person。
$person  $people -> findOne ();

// 解析引用的 address
$address  MongoDBRef :: get ( $people -> db $person [ 'address' ]);

?>

参见

  • MongoDB::getDBRef() - Fetches the document pointed to by a database reference
  • MongoCollection::getDBRef() - Fetches the document pointed to by a database reference
上一篇: 下一篇: