Werbung
MongoDBRef::create
(PECL mongo >= 0.9.0)
MongoDBRef::create — Creates a new database reference
Beschreibung
If no database is given, the current database is used.
Parameter-Liste
- collection
-
Collection name.
- id
-
The _id field of the object to which to link.
- database
-
Database name.
Rückgabewerte
Returns the reference.
Beispiele
PHP Code
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
$addresses = $db->addresses;
$people = $db->people;
// save $address so it has an _id
$addresses->insert($address);
// create a reference
$ref = MongoDBRef::create($addresses->name, $address['_id']);
// set the field in $person
$person['address'] = $ref;
$people->save($person);
Siehe auch
- MongoDB::createDBRef - Creates a database reference
- MongoCollection::createDBRef - Creates a database reference