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条)

报告相同问题?

悬赏问题

  • ¥15 Opencv配置出错
  • ¥15 模电中二极管,三极管和电容的应用
  • ¥15 关于模型导入UNITY的.FBX: Check external application preferences.警告。
  • ¥15 气象网格数据与卫星轨道数据如何匹配
  • ¥100 java ee ssm项目 悬赏,感兴趣直接联系我
  • ¥15 微软账户问题不小心注销了好像
  • ¥15 x264库中预测模式字IPM、运动向量差MVD、量化后的DCT系数的位置
  • ¥15 curl 命令调用正常,程序调用报 java.net.ConnectException: connection refused
  • ¥20 关于web前端如何播放二次加密m3u8视频的问题
  • ¥15 使用百度地图api 位置函数报错?