MongoDBRef
PHP Manual

MongoDBRef::create

(PECL mongo >= 0.9.0)

MongoDBRef::createCreates a new database reference

Opis

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

Parametry

ns

Database and collection name.

id

The id of the object to link.

Zwracane wartości

Returns the reference.

Przykłady

Przykład #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);
?>

Zobacz też:


MongoDBRef
PHP Manual