PHP Class MongoDBRef

显示文件 Open project: alcaeus/mongo-php-adapter Class Usage Examples

Protected Properties

Property Type Description
$idKey
$refKey

Public Methods

Method Description
create ( string $collection, mixed $id, string $database = null ) : array If no database is given, the current database is used.
get ( MongoDB $db, array $ref ) : array | null Fetches the object pointed to by a reference
isRef ( mixed $ref ) : boolean This not actually follow the reference, so it does not determine if it is broken or not.

Method Details

create() public static method

If no database is given, the current database is used.
public static create ( string $collection, mixed $id, string $database = null ) : array
$collection string Collection name (without the database name)
$id mixed The _id field of the object to which to link
$database string Database name
return array Returns the reference

get() public static method

Fetches the object pointed to by a reference
public static get ( MongoDB $db, array $ref ) : array | null
$db MongoDB Database to use
$ref array Reference to fetch
return array | null Returns the document to which the reference refers or null if the document does not exist (the reference is broken)

isRef() public static method

It merely checks that $ref is in valid database reference format (in that it is an object or array with $ref and $id fields).
public static isRef ( mixed $ref ) : boolean
$ref mixed Array or object to check
return boolean Returns true if $ref is a reference

Property Details

$idKey protected_oe static_oe property

protected static $idKey

$refKey protected_oe static_oe property

protected static $refKey