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

search for in the

MongoCollection::getIndexInfo> <MongoCollection::__get
[edit] Last updated: Fri, 25 May 2012

view this page in

MongoCollection::getDBRef

(PECL mongo >=0.9.0)

MongoCollection::getDBRefデータベース参照が指すドキュメントを取得する

説明

public array MongoCollection::getDBRef ( array $ref )

パラメータ

ref

データベース参照。

返り値

参照が指し示すデータベースドキュメントを返します。

例1 MongoCollection::getDBRef() の例

<?php

$playlists 
$db->playlists;

$myList $playlists->findOne(array('username' => 'me'));

// プレイリストの各曲を取得します
foreach ($myList['songlist'] as $songRef) {
    
$song $playlists->getDBRef($songRef);
    echo 
$song['title'] . "\n";
}

?>

上の例の出力は、 たとえば以下のようになります。

Dazed and Confused
Ma na ma na
Bohemian Rhapsody

上の例で、それぞれの $songRef の中身は次のような形式になります。
    Array
    (
        [$ref] => songs
        [$id] => 49902cde5162504500b45c2c
    )
    

参考



add a note add a note User Contributed Notes MongoCollection::getDBRef
manuel at dziubas dot de 17-Apr-2011 10:10
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 | sitemap | contact | advertising | mirror sites