PHP code example of laudis / graphaware-neo4j-bolt-legacy
1. Go to this page and download the library: Download laudis/graphaware-neo4j-bolt-legacy library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laudis / graphaware-neo4j-bolt-legacy example snippets
use GraphAware\Bolt\GraphDatabase;
$driver = GraphDatabase::driver("bolt://localhost");
$session = $driver->session();
$session = $driver->session();
$session->run("CREATE (n)");
$session->close();
// with parameters :
$session->run("CREATE (n) SET n += {props}", ['name' => 'Mike', 'age' => 27]);
use GraphAware\Common\Collections;
$query = 'MERGE (n:User {id: {id} })
WITH n
UNWIND {friends} AS friend
MERGE (f:User {id: friend.name})
MERGE (f)-[:KNOWS]->(n)';
$params = ['id' => 'me', 'friends' => Collections::asList([])];
$this->getSession()->run($query, $params);
// Or
$query = 'MERGE (n:User {id: {id} })
WITH n
UNWIND {friends}.users AS friend
MERGE (f:User {id: friend.name})
MERGE (f)-[:KNOWS]->(n)';
$params = ['id' => 'me', 'friends' => Collections::asMap([])];
$this->getSession()->run($query, $params);