dev-master
9999999-devSimple GraphDB wrapper for easy db access
MIT
The Requires
by Rudie Dirkx
1.0
1.0.0.0Simple GraphDB wrapper for easy db access
MIT
The Requires
by Rudie Dirkx
Simple GraphDB wrapper for easy db access
use GraphAware\Neo4j\Client\ClientBuilder; use rdx\graphdb\Database; // Use graphaware/neo4j-php-client for the complicated connection stuff $client = ClientBuilder::create() ->addConnection('default', CONNECTION_URL_HERE) ->build(); // Add a very simple wrapper for easy access $db = new Database($client);
one(query, params)
:, (*1)
$user = $db->one('MATCH (u:User) WHERE u.name = {name} RETURN u', ['name' => 'Alice']);
many(query, params)
:, (*2)
$users = $db->many('MATCH (u:User) WHERE u.age > {age} RETURN u.name, u.age', ['age' => 30]);
execute(query, params)
:, (*3)
$data = ['age' => 30, 'hobbies' => ['parking', 'waiting']]; $db->execute('MATCH (u:User) WHERE u.name = {name} SET u += {data}', compact('name', 'data'));
Works for one()
, many()
and execute()
. Takes care of params
., (*4)
use rdx\graphdb\Query; $data = ['since' => time()]; $db->execute(Query::make() ->match('(p1:Person)') ->match('(p2:Person)') ->where('p1.name = {person1}', compact('person1')) ->where('p2.name = {person2}', compact('person2')) ->create('(p1)-[:IS_FRIENDS_WITH {data}]->(p2)', compact('data')) ); $db->many(Query::make() ->match('(p1)-[f:IS_FRIENDS_WITH]->(p2)') ->return('p1', 'p2', 'f.since AS since', 'id(f) AS fid') ->order('p1.name ASC', 'p2.name ASC') );
Simple GraphDB wrapper for easy db access
MIT
Simple GraphDB wrapper for easy db access
MIT