我使用了以下命令行:
:POST /db/data/transaction/commit {"statements":[{"statement":"match n return n"}]}当我将此查询设置为PHP变量时,会得到以下错误:
Fatal error: Uncaught exception 'Neoxygen\NeoClient\Exception\Neo4jException' with message 'Neo4j Exception with code "Neo.ClientError.Statement.InvalidSyntax" and message "Invalid input ':' in C:\wamp\www\PhpProjectNeo4j1\vendor\neoxygen\neoclient\src\Extension\AbstractExtension.php on line 88请您向我解释一下,如何在PHP中添加这个命令?
发布于 2015-08-13 22:03:47
您看过NeoClient文档了吗?
唯一的用法是:
$result = $client->sendCypherQuery('MATCH (n) RETURN n')->getResult();
如果您想要导出到json,客户机中没有魔法,只需使用返回的节点对象,创建一个数组并将其编码为json:
$nodes = [];
foreach ($result->getNodes() as $node) {
$nodes[] = [
'id' => $node->getId(),
'labels' => $node->getLabels(),
'properties' => $node->getProperties()
];
}
var_dump(json_encode($nodes));编辑:
为了获得结果对象,需要启用ResponseFormatting服务:
例子:
$client = ClientBuilder::create()
->addDefaultLocalConnection()
->setAutoFormatResponse(true)
->build();https://stackoverflow.com/questions/31997517
复制相似问题