class MongoDBRef (View source)

Properties

static protected string $refKey
static protected string $idKey

Methods

static array
create(string $collection, mixed $id, string $database = null)

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

static bool
isRef(mixed $ref)

This not actually follow the reference, so it does not determine if it is broken or not.

static array|null
get(MongoDB $db, array $ref)

Fetches the object pointed to by a reference

Details

static array create(string $collection, mixed $id, string $database = null)

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

Parameters

string $collection

Collection name (without the database name)

mixed $id

The _id field of the object to which to link

string $database

Database name

Return Value

array

Returns the reference

static bool isRef(mixed $ref)

This not actually follow the reference, so it does not determine if it is broken or not.

It merely checks that $ref is in valid database reference format (in that it is an object or array with $ref and $id fields).

Parameters

mixed $ref

Array or object to check

Return Value

bool

Returns true if $ref is a reference

static array|null get(MongoDB $db, array $ref)

Fetches the object pointed to by a reference

Parameters

MongoDB $db

Database to use

array $ref

Reference to fetch

Return Value

array|null

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