这是我的omg课程:
/**
* @OGM\Node(label="Personne")
*/
class Personne
{
/**
* @OGM\GraphId()
*/
protected $id;
/**
* @OGM\Property(type="string")
*/
protected $nom;
/**
* @OGM\Relationship(targetEntity="Personne", type="SUIT", direction="OUTGOING")
*/
protected $amis;
我使用这段代码:
$marc = $this->em->getRepository(Personne::class)->findOneBy('nom', 'marc');
print_r($marc->getAmis());
但它只返回1个关系,而不是全部,有什么问题?
答案 0 :(得分:1)
它只返回一个相关的" Personne"因为您没有将amis
属性定义为映射中的集合:
在collection=true
注释中添加@OGM\Relationship
。
注意:在PHP 7.1中,类型属性可以使用,OGM的未来版本可能会利用它(意味着此版本仅为7.1+)
实际上,我认为OGM应该抛出异常,以防发现多个关系。