downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

MongoDBRef::get> <MongoDBRef
[edit] Last updated: Fri, 23 Mar 2012

view this page in

MongoDBRef::create

(PECL mongo >= 0.9.0)

MongoDBRef::createCreates a new database reference

Açıklama

public static array MongoDBRef::create ( string $collection , mixed $id [, string $database ] )

If no database is given, the current database is used.

Değiştirgeler

collection

Collection name (without the database name).

id

The _id field of the object to which to link.

database

Database name.

Dönen Değerler

Returns the reference.

Örnekler

Örnek 1 MongoDBRef::create() example

This creates a database reference to a document in the addresses collection. The MongoCollection::getName() function returns the name of the collection (not including the database name).

<?php
$addresses 
$db->addresses;
$people $db->people;

// save $address so it has an _id
$addresses->insert($address);

// create a reference
$ref MongoDBRef::create($addresses->getName(), $address['_id']);

// set the field in $person
$person['address'] = $ref;
$people->save($person);
?>

Ayrıca Bakınız



add a note add a note User Contributed Notes MongoDBRef::create
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites