my szenario in detail, iv’e got one User Document:
/** @Document(collection="user") */
class User
{
/** @Id */
private $id;
/** @ReferenceMany(targetDocument="Pet") */
private $pet;
public function getPet()
{
return $this->pet;
}
}
and iv’e got one Pet document:
/** @Document(collection="pet") */
class Pet
{
/** @Id */
private $id;
/** @ReferenceMany(targetDocument="User") */
private $user;
public function getUser()
{
return $this->user;
}
}
A many to many correlation. If i call the following code for an existing document…
$result = $this->_dbContainer->getDocumentManager()->getRepository('User')->findBy(array('id' => => 'XZTZHJ323LKFHGJKLHGFGHJK'));
print_r($result->toArray());
…it ends in an endless loop. Error message:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 112721921 bytes) in ...
If i execute the following code:
var_dump($result->count());
The result ist one / it exist (everything ok). A var_dump of $result->current() is NULL. The method getMongoData returns the following data (which is correct):
Array ( [0] => Array ( [$ref] => example [$id] => MongoId Object ( [$id] => 4ddac7667294c79e17000002 ) [$db] => test ) )
If i execute the following code:
var_dump($result->current());
The result is boolean (false).
Any ideas?
Provided your model looks something like this
You should be able to retrieve the referenced models using
Do not attempt to
var_dump()orprint_r()the model proxy objects. These contain many recursive references and you will exhaust your available memory attempting to render them as output.