Database Reference
In-Depth Information
Listing 8-7. Deleting a Node
<?php
// Neo4jClient class
// ...omitted...
// Create Neo4j client
// ...omitted...
// retrieve the node by its node id value, in this case 10
$user = $neo4jClient->getNode(10);
// delete the node
$user->delete();
Creating a Relationship
Neo4jPHP offers two different methods for creating relationships: one using the relateTo method; the other using the
makeRelationship method. The example in Listing 8-8 sets up the relationship using the relateTo method, which is the
less verbose of the two options.
Both the start and end nodes of a relationship must already be established within the database before the
relationship can be saved.
Note
Listing 8-8. Relating Two Nodes
<?php
// Neo4jClient class
// ...omitted...
// Create Neo4j client
// ...omitted...
// retrieve the node by its node id value, in this case 10
$greg = $neo4jClient->getNode(10);
// retrieve the node by its node id value, in this case 1
$jeremy = $neo4jClient->getNode(1);
// populate & save the relationship ($greg follows $jeremy)
$greg->relateTo($jeremy,'FOLLOWS')->save();
 
 
Search WWH ::




Custom Search