MongoCollection::getDBRef PHP Method

getDBRef() public method

Fetches the document pointed to by a database reference
public getDBRef ( array $ref ) : array
$ref array A database reference.
return array Returns the database document pointed to by the reference.
    public function getDBRef(array $ref)
    {
        return $this->db->getDBRef($ref);
    }

Usage Example

 public function testGetDBRef()
 {
     for ($i = 0; $i < 50; $i++) {
         $this->object->insert(array('x' => rand()));
     }
     $obj = $this->object->findOne();
     $ref = $this->object->createDBRef($obj);
     $obj2 = $this->object->getDBRef($ref);
     $this->assertNotNull($obj2);
     $this->assertEquals($obj['x'], $obj2['x']);
 }
All Usage Examples Of MongoCollection::getDBRef