0

そのために、次のコマンドラインを使用しました。

: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 に追加する方法を教えてください。

4

1 に答える 1

0

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();
于 2015-08-13T22:03:47.727 に答える