Database Reference
In-Depth Information
Retrieving Relationships
Once a relationship has been created between one or more nodes, the relationship can be retrieved based on a node.
Listing 8-9. Retrieving Relationships
<?php
// Neo4jClient class
// ...omitted...
// Create Neo4j client
// ...omitted...
// retrieve the node by its node id value, in this case 10
$greg = $neo4jClient->getNode(10);
// get all relationships
$gregRels = $greg->getRelationships();
// get relationships based on relationship named 'FOLLOWS'
$ gregKNOWSRels = $greg->getRelationships(array('FOLLOWS'));
Deleting a Relationship
Once a relationship's graph id has been set and saved into the database, it becomes eligible to be removed when
necessary. In order to remove a relationship, it must be set as a relationship object instance and then the delete
method for the relationship can be called.
Listing 8-10. Deleting a Relationship
<?php
// Neo4jClient class
// ...omitted...
// Create Neo4j client
// ...omitted...
// retrieve the Relationshipby its Relationship id value, in this case 20
$rel = $client->getRelationship(20);
// delete the relationship
$rel->delete();
Using Labels
Labels function as specific meta-descriptions that can be applied to nodes. Labels were introduced in Neo4j 2.0 to
help in querying, and they can also function as a way to quickly create a sub-graph.
 
Search WWH ::




Custom Search