-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME
More file actions
45 lines (32 loc) · 2.14 KB
/
README
File metadata and controls
45 lines (32 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
This is a Basic CodeIgniter Library for the Neo4j Graph Database's REST server. Requesting contributions towards developing this library. The Wrapper Helps you communicate with the Neo4j REST Server. You can request for the results in JSON or a php Array. The Best way to Implement this would be to keep REST Server documentation as reference and mould the examples below to get what you need done.
Refer Documentation at : http://components.neo4j.org/neo4j-server/snapshot/rest.html
Installation :
Copy Neoapi.php inside your /htdocs/<your-ci-project>/application/libraries Folder
Usage :
Please Note : The library assumes that the Neo4j Services are running and active on the default port (localhost:7474) and default authentication.
You may need to change the values at Neoapi.php to reflect your REST Server's settings.
Blow is a sample implementation in your CI controller function
// INCLUDE THE LIBRARY
$this->load->library('nodeapi');
// CHECK IF NEO4J SERVER IS ONLINE
if (!$this->neoapi->isServerOnline()){
echo 'Neo4js graph server is offline' ;
exit ;
}
// CREATE A NODE
$nodeA = $this->neoapi->request('db/data/node', array ('name' => 'manchester_united', 'type' => 'football_club'));
// CREATE ANOTHER NODE AND FORM A RELATIONSHIP
$nodeB = $this->neoapi->request('db/data/node', array ('name' => 'wayne_Rooney', 'type' => 'player'));
$this->neoapi->request ($nodeA['self'].'/relationships/', array ('to' => $nodeB['self'], 'type' => 'has_player'));
$this->neoapi->request ($nodeB['self'].'/relationships/', array ('to' => $nodeA['self'], 'type' => 'plays_for'));
// CREATE AN INDEX
$index = $this->neoapi->request('db/data/index/node/', array ('name' => 'football_clubs'));
$indexTemplate = $index['template'];
// INDEX THE 'name' FIELD OF NODE
$nameIndex = str_replace('{key}', 'name', $indexTemplate);
$nameIndex = str_replace('{value}', 'manchester_united', $nameIndex);
$this->neoapi->request($nameIndex, $nodeA['self']);
// DELETE A NODE
$this->neoapi->delete('db/data/node/'.$this->neoapi->getNodeId($nodeA));
// BASIC NODE TRAVERSAL : GET NODES RELATED TO A NODE
$relatedNodes = $this->neoapi->request($nodeA['self'].'/relationships/out/has_player');