예제 #1
0
 public static function addStudent()
 {
     $input = Input::all();
     $student = Neo4j::makeNode();
     $date = new DateTime();
     $timestamp = $date->getTimestamp();
     $id = uniqid();
     $student->setProperty('id', $id)->setProperty('password', Hash::make($input['password']))->setProperty('name', $input['name'])->setProperty('email', $input['email'])->save();
     $label = Neo4j::makeLabel('STUDENT');
     $label2 = Neo4j::makeLabel('USER');
     $student->addLabels(array($label, $label2));
     if ($student) {
         return true;
     } else {
         return false;
     }
 }
예제 #2
0
 public static function addInternship($input)
 {
     $employer = Self::getEmployersDetails(Session::get('eid'));
     $post = Neo4j::makeNode();
     $date = new DateTime();
     $timestamp = $date->getTimestamp();
     $id = uniqid();
     $post->setProperty('id', $id)->setProperty('title', $input['title'])->setProperty('forThePost', $input['forThePost'])->setProperty('moreInfo', $input['moreInfo'])->setProperty('company', $employer['company'])->setProperty('timestamp', $timestamp)->save();
     $label = Neo4j::makeLabel('POST');
     $post->addLabels(array($label));
     $postDetails = $post->getProperties();
     $client = new Everyman\Neo4j\Client('localhost', 7474);
     $queryString = "MATCH (n: POST {id: '" . $postDetails['id'] . "'}),(m:EMPLOYER {id: '" . $employer['id'] . "'}) CREATE (m)-[r :ADDED]->n";
     $query = new Everyman\Neo4j\Cypher\Query($client, $queryString);
     $result = $query->getResultSet();
     if ($post) {
         return $post;
     } else {
         return false;
     }
 }
예제 #3
0
<?php

/**
 *	Include the API PHP file
 */
require 'neo4j.class.php';
$graphDb = new Neo4j();
$graphDb->setBaseUri('http://localhost:7474/');
$firstNode = $graphDb->createNode();
$secondNode = $graphDb->createNode();
$thirdNode = $graphDb->createNode();
$firstNode->name = "Hello, ";
$firstNode->id = 123;
$firstNode->save();
$firstNode->id = NULL;
// Setting to null removes the property
$firstNode->save();
$secondNode->name = "world!";
$secondNode->id = 345;
$secondNode->save();
$thirdNode->id = 11;
$thirdNode->save();
/**
 *	Create a relationship between some nodes. These can also have attributes.
 *	Note: Relationships also need to be saved before they exist in the DB.
 */
$relationship = $firstNode->createRelationshipTo($secondNode, 'KNOWS');
$relationship->name = "brave Neo4j";
$relationship->id = 222;
$relationship->save();
$relationship->id = NULL;
예제 #4
0
 public function testCheckFailsIfNoNeo4jServerIsRunning()
 {
     $check = new Neo4j();
     $result = $check->check();
     $this->assertInstanceOf('ZendDiagnostics\\Result\\Failure', $result);
 }