MongoCollection
在线手册:中文 英文
PHP手册

MongoCollection::createDBRef

(PECL mongo >=0.9.0)

MongoCollection::createDBRefCreates a database reference

说明

public array MongoCollection::createDBRef ( array $a )

参数

a

Object to which to create a reference.

返回值

Returns a database reference array.

范例

Example #1 MongoCollection::createDBRef() example

<?php

$songs 
$db->songs;
$playlists $db->playlists;

// create a reference to a song
$manamana $songs->findOne(array('title' => 'Ma na ma na'));
$refToSong $songs->createDBRef($manamana);

// add the reference to my playlist
$playlists->update(array('username' => 'me'), array('$push' => array('songlist' => $refToSong)));

?>

参见


MongoCollection
在线手册:中文 英文
PHP手册