3

I am new to neo4j and neo4j-php-clien, and following the tutorial in Basic Usage.

This is what I have:

$result = $client->run("MATCH (n:Person) RETURN n");

echo var_dump ($result->getRecords());

this is the output:

object(GraphAware\Neo4j\Client\Formatter\RecordView)#31 (3) { ["keys":protected]=> array(1) { [0]=> string(1) "n" } ["values":protected]=> array(1) { [0]=> object(GraphAware\Neo4j\Client\Formatter\Type\Node)#40 (3) { ["id":protected]=> int(187) ["labels":protected]=> array(1) { [0]=> string(8) "X2Person" } ["properties":protected]=> array(2) { ["name"]=> string(4) "Ales" ["age"]=> int(34) } } } ["keyToIndexMap":"GraphAware\Neo4j\Client\Formatter\RecordView":private]=> array(1) { ["n"]=> int(0) } }

How can I access the protected and private fields of the record?

Pang
  • 9,564
  • 146
  • 81
  • 122
garry
  • 51
  • 2
  • I have already tried $record = $result->getRecord(); $record->value('age'); None of the methods except $record->values() works. – garry Sep 17 '16 at 06:55

2 Answers2

2

I think I finally figured out; I need a reference to the node first.

This works for me:

$query = "MATCH (n:Person) return n";

$result = $client->run($query);

$record=$result->getRecord();

$xNode=$record->get('n');

echo $xNode->value('name')."
";

var_dump($xNode->labels());

....

garry
  • 51
  • 2
0

There is a section in the documentation : Working with Result Sets, which details completely the next operations

https://github.com/graphaware/neo4j-php-client#working-with-result-sets

Christophe Willemsen
  • 19,399
  • 2
  • 29
  • 36