duanjianlu0506 2013-06-28 12:33
浏览 281
已采纳

使用PHP中的neo4j-OGM为neo4j数据库中的关系添加属性

while we are able to create new nodes etc., we are still struggling to find out how properties can be added to existing relationships. For instance we are declaring the following in an Entity format:

   /**
     * @OGM\ManyToMany(relation="GOES_TO_MARKET")
     */
    protected $shoppers;

How do we make it so that we can add additional properties to GOES_TO_MARKET using doctrine format?

Thanks

  • 写回答

2条回答 默认 最新

  • douba9425 2013-06-28 12:56
    关注

    There is no direct way to do it through the API at this time. While there is some work in progress, it is quite far from completed.

    You can register a callback on relation creation.

    $em->registerEvent(HireVoice\Neo4j\EntityManager::RELATION_CREATE, function ($type, $relationName, $from, $to, $relation) {
        // $relation is the Everyman\Neo4j\Relationship
        if ($relationName === 'GOES_TO_MARKET') {
            $relation->setProperty('foobar', 'baz')->save();
        }
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!