downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

MongoCollection::getIndexInfo> <MongoCollection::__get
[edit] Last updated: Fri, 24 May 2013

view this page in

MongoCollection::getDBRef

(PECL mongo >=0.9.0)

MongoCollection::getDBRefFetches the document pointed to by a database reference

Açıklama

public array MongoCollection::getDBRef ( array $ref )

Değiştirgeler

ref

A database reference.

Dönen Değerler

Returns the database document pointed to by the reference.

Örnekler

Örnek 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";
}

?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

Dazed and Confused
Ma na ma na
Bohemian Rhapsody

In the above example each $songRef looks something like the following:
    Array
    (
        [$ref] => songs
        [$id] => 49902cde5162504500b45c2c
    )
    

Ayrıca Bakınız



add a note add a note User Contributed Notes MongoCollection::getDBRef - [1 notes]
up
1
manuel at dziubas dot de
2 years ago
The "$id" has to be a

new MongoId("...")

in PHP driver!

Ref:
array(
  "$ref" => "other_collection",
  "$id" => new MongoId("the_referenced_dataobject_id")
)

 
show source | credits | stats | sitemap | contact | advertising | mirror sites