(PECL mongo >= 0.9.0)
MongoDBRef::create — 锟斤拷锟斤拷一锟斤拷锟铰碉拷锟斤拷锟捷匡拷锟斤拷锟斤拷
This extension that defines this class is deprecated. Instead, the MongoDB extension should be used. There is no equivalent for this class in the new extension.
锟斤拷锟捷匡拷锟斤拷锟矫o拷database reference锟斤拷 锟侥革拷锟筋,锟斤拷锟揭达拷锟斤拷锟窖撅拷锟斤拷锟斤拷锟矫★拷
锟斤拷锟矫伙拷锟街革拷锟斤拷锟斤拷菘猓拷锟斤拷锟绞癸拷玫锟角帮拷锟斤拷菘狻�
collection
锟斤拷锟斤拷锟斤拷锟狡o拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷匡拷锟斤拷锟斤拷锟斤拷
id
要锟斤拷锟接的讹拷锟斤拷锟� _id 锟街段★拷
database
锟斤拷锟捷匡拷锟斤拷锟斤拷
锟斤拷锟斤拷锟斤拷锟矫★拷
Example #1 MongoDBRef::create() 锟斤拷锟斤拷
锟斤拷锟斤拷锟斤拷锟轿拷牡锟斤拷锟斤拷锟斤拷锟揭伙拷锟� addresses 锟斤拷锟斤拷锟捷匡拷锟斤拷锟矫★拷 MongoCollection::getName() 锟斤拷锟斤拷锟斤拷锟截硷拷锟较碉拷锟斤拷锟街o拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷匡拷锟斤拷锟斤拷锟斤拷
<?php
$addresses = $db->addresses;
$people = $db->people;
// 锟斤拷锟斤拷 $address锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷 _id
$addresses->insert($address);
// 锟斤拷锟斤拷锟斤拷锟斤拷
$ref = MongoDBRef::create($addresses->getName(), $address['_id']);
//锟斤拷锟斤拷 $person 锟斤拷锟斤拷侄锟�
$person['address'] = $ref;
$people->save($person);
?>