跳至正文
-
关注
IT极限技术分享汇

ITmax

IT极限技术分享汇

ITmax

  • 首页
  • 商店
  • 我的帐户
  • 结账
  • 购物车
  • 首页
  • 商店
  • 我的帐户
  • 结账
  • 购物车
关

搜索

图数据库neo4j的PHP库

作者
2022年7月25日 1 分钟阅读
0

git 项目地址 church/neo4j

介绍

基于PHP的neo4j库,源文档链接地址 neo4j http api

安装环境需求

  • PHP >= 7.4

安装

composer require church/neo4j

用法

初始化

$app = new /Church/Neo4j/Application("http://127.0.0.1:7474", "neo4j", "neo4j");
$app->discovery();

查询语句

$statement = (new /Church/Neo4j/Statement('CREATE (n $props) RETURN n)'))->params([
    'props' => [
        'name' => 'test'
    ]   
]);

开启事务

$statements = /Church/Neo4j/StatementRepository::add($statement);
$transaction = $app->transaction($statements);
$transaction->begin();

提交事务

$result = $transaction->commit();

if ($result->getRawResponse()->getStatusCode() == 200) {
    print_r($result->getData());
}

延长事务有效期

default expiry time is 60 seconds.

$transaction->keepAlive(); 

回滚

$transaction->rollback();

开启和提交事务

$result = $transaction->beginAndCommit();
print_r($result);

单元测试

composer install
./vendor/bin/phpunit

协议

MIT

https://segmentfault.com/a/1190000042219418

作者

关注我
其他文章
上一个

从业务开发中学习和理解架构设计

下一个

Code Runner for VS Code,下载量突破 4000 万!支持超过50种语言

暂无评论!成为第一个。

发表回复 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Copyright 2026 — IT极限技术分享汇. 备案号:浙ICP备17006560号-2