neo4j ogm不会返回所有关系

时间:2016-05-28 02:50:48

标签: php neo4j graphaware neo4j-php-ogm

这是我的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个关系,而不是全部,有什么问题?

1 个答案:

答案 0 :(得分:1)

它只返回一个相关的" Personne"因为您没有将amis属性定义为映射中的集合:

collection=true注释中添加@OGM\Relationship

注意:在PHP 7.1中,类型属性可以使用,OGM的未来版本可能会利用它(意味着此版本仅为7.1+)

实际上,我认为OGM应该抛出异常,以防发现多个关系。