MongoDBRef::get

(PECL mongo >= 0.9.0)
Fetches the object pointed to by a reference
public static array MongoDBRef::get ( MongoDB $db, array $ref )
Parameters:
db

Database to use.

ref

Reference to fetch.

Returns:

Returns the document to which the reference refers or NULL if the document does not exist (the reference is broken).

Examples:
MongoCollection::createDBRef() example
1
2
3
4
5
6
7
8
9
<?php
 
// get $person out of the db
$person $people->findOne();
 
// dereference the address
$address = MongoDBRef::get($people->db, $person['address']);
 
?>
See also:

MongoDB::getDBRef() -

MongoCollection::getDBRef() -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.