Home > Backend Development > PHP Tutorial > Share a neo4j (graph database) PHP library!

Share a neo4j (graph database) PHP library!

藏色散人
Release: 2023-04-11 07:16:01
forward
3374 people have browsed it

git project address church/neo4j: https://github.com/fireqong/neo4j

Introduction

Neo4j based on PHP Library, which can help you connect to neo4j's PHP library more conveniently. Source document link address neo4j http api: https://neo4j.com/docs/http-api/current/actions/

Installation Environmental requirements

PHP >= 7.4

Installation

composer require church/neo4j
Copy after login

Usage

Initialization

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

Query statement

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

Open transaction

$statements = \Church\Neo4j\StatementRepository::add($statement);
$transaction = $app->transaction($statements);
$transaction->begin();
Copy after login

Submit transaction

$result = $transaction->commit();

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

Extend transaction validity period

default expiry time is 60 seconds.$transaction->keepAlive();
Copy after login

Rollback

$transaction->rollback();
Copy after login

Open and commit transactions

$result = $transaction->beginAndCommit();print_r($result);
Copy after login

Unit test

composer install
./vendor/bin/phpunit
Copy after login

The above is the detailed content of Share a neo4j (graph database) PHP library!. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template