【问题标题】:neo4j-php-client private and protected fieldsneo4j-php-client 私有和受保护字段
【发布时间】:2017-01-25 06:55:12
【问题描述】:

我是 neo4j 和 neo4j-php-clien 的新手,并遵循基本用法中的教程。

这就是我所拥有的:

$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('年龄');除了 $record->values() 之外的方法都不起作用。

标签: php neo4j graphaware


【解决方案1】:

我想我终于想通了;我首先需要对节点的引用。

这对我有用:

$query = "MATCH (n:Person) 返回 n";

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

$record=$result->getRecord();

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

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

var_dump($xNode->labels());

....

【讨论】:

【解决方案2】:

文档中有一节:Working with Result Sets,详细介绍了接下来的操作

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

【讨论】:

    猜你喜欢
    • 2011-07-09
    • 2015-08-11
    • 2014-04-26
    • 2017-08-22
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 2013-04-04
    • 1970-01-01
    相关资源
    最近更新 更多