This library contains wrapper class to cover basic functionality with Bolt library.
Run the following command in your project to install the latest applicable version of the package:
composer require stefanak-michal/neo4j-bolt-wrapper
Neo4j::$auth = ['scheme' => 'basic', 'principal' => 'neo4j', 'credentials' => 'password'];
$rows = Neo4j::query('RETURN $n as num', ['n' => 123]);
You can also use methods like queryFirstField
and queryFirstColumn
.
If you want to learn more about available query parameters check Bolt library readme.
Default connection is executed on 127.0.0.1:7687. You can change target server with static properties:
Neo4j::$host = 'neo4j+s://demo.neo4jlabs.com';
Neo4j::$port = 7687;
Transaction methods are:
Neo4j::begin();
Neo4j::commit();
Neo4j::rollback();
You can set callable function into Neo4j::$logHandler
which is called everytime query is executed. Method will receive executed query with additional statistics.
Check class property annotation for more information.
Standard behaviour on error is trigger_error with E_USER_ERROR. If you want to handle Exception by yourself you can set callable function into Neo4j::$errorHandler
.
Wrapper offers special method Neo4j::statistic()
. This method returns specific information from last executed query.
Check method annotation for more information.