(PECL mongo >=0.9.0)
MongoDB::createDBRef — 创建数据库引用
这个方法是一个创建数据库引用的扩展接口(参考MongoDBRef)
collection
     数据库引用指向的集合
document_or_id
     如果是一个数组或对象,它的 _id 字段将被用做引用ID,如果是一个 MongoId 对象或简单变量,它本身将作为引用ID。
返回一个数据库引用数组。
   如果一个没有
   _id
   字段的数组作为
   document_or_id
   参数,NULL会被返回。
  
Example #1 MongoDB::createDBRef()实例
演示如何从程序中创建文档的数据库引用。
<?php
$articles = $db->articles;
$article = array(
 'title' => 'Test article',
 'description' => 'Test article description'
);
$articles->insert($article);
$ref = $db->createDBRef('articles', $article);
print_r($article);
print_r($ref);
?>
以上例程的输出类似于:
     Array
     (
         [title] => Test article
         [description] => Test article description
         [_id] => MongoId Object
             (
             )
     )
     Array
     (
         [$ref] => articles
         [$id] => MongoId Object
             (
             )
     )
     现在$ref可以被保存到另一个文档中,并在之后通过 MongoDB::getDBRef()或MongoCollection::getDBRef() 方法取回。
Example #2 MongoDB::createDBRef()实例
演示如何在程序中值通过一个id创建数据库引用。
<?php
$id = new MongoId('47cc67093475061e3d9536d2');
$ref = $db->createDBRef('articles', $id);
?>