(PECL mongo >=0.9.0)
MongoCollection::createDBRef — 锟斤拷锟斤拷一锟斤拷锟斤拷锟捷匡拷锟斤拷锟斤拷
document_or_id
If an array or object is given, its _id field will be used as the reference ID. If a MongoId or scalar is given, it will be used as the reference ID.
锟斤拷锟斤拷一锟斤拷锟斤拷锟捷匡拷锟斤拷锟斤拷锟斤拷锟斤拷椤�
锟斤拷锟斤拷峁╋拷瞬锟斤拷锟斤拷锟� _id 锟街段碉拷锟斤拷锟介当锟斤拷 document_or_id 锟斤拷锟斤拷锟斤拷锟斤拷锟结返锟斤拷 NULL
锟斤拷
Example #1 MongoCollection::createDBRef() 锟斤拷锟斤拷
<?php
$songs = $db->songs;
$playlists = $db->playlists;
// 为 song 锟斤拷锟斤拷锟斤拷锟斤拷
$manamana = $songs->findOne(array('title' => 'Ma na ma na'));
$refToSong = $songs->createDBRef($manamana);
// 锟斤拷锟斤拷锟斤拷玫锟斤拷业牟锟斤拷锟斤拷斜锟�
$playlists->update(array('username' => 'me'), array('$push' => array('songlist' => $refToSong)));
?>