neo4j-php-client的私有和受保护字段

3

我是neo4j和neo4j-php-client的新手,正在按照基本用法教程进行学习。

这是我的代码:

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

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

以下是输出结果:

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) } }

如何访问记录中受保护和私有字段?


我已经尝试过以下代码:$record = $result->getRecord();$record->value('age');除了$record->values()方法之外,其他方法都无效。 - garry
2个回答

2
我想我终于明白了,我需要先引用节点。
以下对我有用: $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()); ....

是的,这个已经在https://github.com/graphaware/neo4j-php-client#record-value中解释了。 - Christophe Willemsen

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接