MongoDBRef
MongoDBRef::get
MongoDBRef
PHP Manual

# MongoDBRef::create

(PECL mongo >= 0.9.0)

MongoDBRef::create — Creates a new database reference

### Description

public static array MongoDBRef::create ( string `$ns` , mixed `$id` )

### Parameters

`ns`

  Database and collection name.

`id`

  The id of the object to link.

### Return Values

Returns the reference.

### Examples

Example #1 MongoDBRef::create() example

`<?php
$addresses = $db->selectCollection('addresses');
$people = $db->selectCollection('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);
?>`

### See Also

- MongoDB::createDBRef - Creates a database reference
- MongoCollection::createDBRef - Creates a database reference

MongoDBRef
MongoDBRef::get
MongoDBRef
PHP Manual