https://github.com/xp-forge/neo4j
Neo4J connectivity for XP Framework
https://github.com/xp-forge/neo4j
neo4j php xp-framework
Last synced: 3 months ago
JSON representation
Neo4J connectivity for XP Framework
- Host: GitHub
- URL: https://github.com/xp-forge/neo4j
- Owner: xp-forge
- Created: 2017-09-30T12:15:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-05-04T17:04:42.000Z (about 1 year ago)
- Last Synced: 2025-08-20T19:16:22.534Z (10 months ago)
- Topics: neo4j, php, xp-framework
- Language: PHP
- Size: 78.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
Awesome Lists containing this project
README
Neo4J connectivity
==================
[](https://github.com/xp-forge/neo4j/actions)
[](https://github.com/xp-framework/core)
[](https://github.com/xp-framework/core/blob/master/LICENCE.md)
[](http://php.net/)
[](http://php.net/)
[](https://packagist.org/packages/xp-forge/neo4j)
This library implements Neo4J connectivity via its REST API.
Examples
--------
Running a query can be done via `open()` (which yields one record at a time) or `query()` (which collects the results in an array):
```php
use com\neo4j\Graph;
use util\cmd\Console;
$g= new Graph('http://user:pass@neo4j-db.example.com:7474/db/data');
$q= $g->open('MATCH (t:Topic) RETURN t.name, t.canonical');
foreach ($q as $record) {
Console::writeLine('#', $record['t.canonical'], ': ', $record['t.name']);
}
```
To retrieve single results (or *NULL* if nothing is found), use `fetch()`:
```php
if ($topic= $g->fetch('MATCH (t:Topic{id:%s}) RETURN t', $id)) {
Console::writeLine('Found topic ', $topic);
}
```
Formatting parameters uses *printf*-like format tokens. These will take care of proper escaping and type casting:
```php
use com\neo4j\Graph;
use util\cmd\Console;
$g= new Graph('http://user:pass@neo4j-db.example.com:7474/db/data');
$g->query('CREATE (p:Person) SET t.name = %s, t.id = %d', $name, $id);
```
Batch statements can be executed via the `execute()` method.
Format characters
-----------------
* `%s`: Format a string
* `%d`: Format a decimal number
* `%f`: Format a floating point numer
* `%b`: Format a boolean
* `%v`: Copy value into parameter
* `%l`: Copy label into query
* `%c`: Copy literal into query
* `%%`: A literal percent sign
Positional parameters (starting at 1) may be used, e.g. `%2$s`.