©
이 문서에서는 PHP 중국어 웹사이트 매뉴얼 풀어 주다
(PECL mongo >=0.9.0)
MongoCollection::getDBRef — Fetches the document pointed to by a database reference
$ref
)
ref
A database reference.
Returns the database document pointed to by the reference.
Example #1 MongoCollection::getDBRef() example
<?php
$playlists = $db -> playlists ;
$myList = $playlists -> findOne (array( 'username' => 'me' ));
// fetch each song in the playlist
foreach ( $myList [ 'songlist' ] as $songRef ) {
$song = $playlists -> getDBRef ( $songRef );
echo $song [ 'title' ] . "\n" ;
}
?>
以上例程的输出类似于:
Dazed and Confused Ma na ma na Bohemian Rhapsody
Array ( [$ref] => songs [$id] => 49902cde5162504500b45c2c )
[#1] manuel at dziubas dot de [2011-04-17 10:10:06]
The "$id" has to be a
new MongoId("...")
in PHP driver!
Ref:
array(
"$ref" => "other_collection",
"$id" => new MongoId("the_referenced_dataobject_id")
)