<?php // connection to neo4j require 'vendor/autoload.php'; $client = new Everyman\Neo4j\Client('localhost', 7474); $label = $client->makeLabel('tag'); $file = fopen("./database/tags.dat", "r") or exit("Unable to open file!"); $log = fopen("./database/tags.log", "w") or exit("Unable to open file!"); //Output a line of the file until the end is reache $i = 0; while (!feof($file)) { $line = fgets($file); $atributes = explode("\t", $line); //echo "id = " . $atributes[0] ."\n"; //echo "name = " . $atributes[1] ."\n"; //echo "url = " . $atributes[2] ."\n"; // is_null switch (count($atributes)) { case 0: echo "Linea sin registros\n"; // Do Nothing break; case 1: // Do nothing break; case 2: // Create a tag node $id = (int) trim($atributes[0]); $name = (string) utf8_decode(trim($atributes[1])); fwrite($log, "Reading {$id} | {$name}\n"); if (!is_null($name) and !is_null($name)) {
<?php require 'vendor/autoload.php'; $client = new Everyman\Neo4j\Client('localhost', 7474); $label = $client->makeLabel('user'); for ($i = 2; $i <= 2100; $i++) { // reate the users for test (all the users have the same name: Thomas) $user = $client->makeNode(); $user->setProperty('id', $i)->setProperty('name', 'Thomas')->save(); $labels = $user->addLabels(array($label)); $userId = $user->getId(); //echo "User created with id: " . $bobId; }
/** * Convert a string into a Neo4j Label. * * @param string $label * @return Everyman\Neo4j\Label */ public function makeLabel($label) { return $this->client->makeLabel($label); }
<?php // connection to neo4j require 'vendor/autoload.php'; $client = new Everyman\Neo4j\Client('localhost', 7474); $label = $client->makeLabel('artist'); $file = fopen("./database/artists.dat", "r") or exit("Unable to open file!"); //Output a line of the file until the end is reache $i = 0; while (!feof($file)) { $line = fgets($file); $atributes = explode("\t", $line); //echo "id = " . $atributes[0] ."\n"; //echo "name = " . $atributes[1] ."\n"; //echo "url = " . $atributes[2] ."\n"; // is_null switch (count($atributes)) { case 0: echo "Linea sin registros\n"; // Do Nthing break; case 1: // Do nothing break; case 2: // Only add Artist with id and name $id = $atributes[0]; $name = $atributes[1]; $artist = $client->makeNode(); $artist->setProperty('id', $id)->setProperty('name', $name)->save(); //$artistId = $artist->getId();