PHP code example of graphaware / neoclient-timetree

1. Go to this page and download the library: Download graphaware/neoclient-timetree library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

graphaware / neoclient-timetree example snippets



use Neoxygen\NeoClient\ClientBuilder;

$client = ClientBuilder::create()
    ->addDefaultLocalConnection()
    ->setAutoFormatResponse(true)
    ->registerExtension('graphaware_timetree', 'GraphAware\NeoClientExtension\TimeTree\TimeTreeExtension')
    ->build();

$client->createTimeTreeIndexes();

$today = $client->getTimeNode(time());

use GraphAware\NeoClientExtension\TimeTree\TimeTreeExtension;

$now = $client->getTimeNode(time(), TimeTreeExtension::TIMETREE_RESOLUTION_MILLISECOND);


// Example for adding a node to a timeTree after its creation :

$q = 'CREATE (n:SuperEvent) RETURN n';
$result = $client->sendCypherQuery($q)->getResult();
$nodeId = $result->get('n')->getId();

$client->addNodeToTime($nodeId, time(), 'EVENT_OCCUR_ON');
// Returns true

$result = $client->getTimeEvents(time())->getResult();

// Returns you a collection of nodes, the identifier of the collection is "n"
$events = $result->get('n');

// OR

$events = $result->getNodes();

$result = $client->getTimeEventsInRange(112556325)->getResult();
// Again the identifier is n

$events = $result->get('n');

$result = $client->getTimeEventsInRange(
    112556325, 
    time(), 
    TimeTreeExtension::TIMETREE_RESOLUTION_HOUR
    )->getResult();
// Again the identifier is n

$events = $result->get('n');

$client->addNodeToTimeForRoot($rootNodeId, $eventNodeId, $time, $relationshipType, $resolution, $connection);

$events = $client->getTimeEventsForRoot($rootNodeId, $time);