Reputation: 107
I'm trying to read a cypher return in my php code using GraphAware.
I've tried all found variant of return reading, but none of them works. The count of the array is 1, but when I try to echo the array's elements by index or in a loop, nothing is printed. But, the Neo4j browser returns a set of nodes by the query, so the query is valid.
Assuming we have one matching node:
<?php
require_once 'vendor/autoload.php';
use GraphAware\Neo4j\Client\ClientBuilder;
$client = ClientBuilder::create()
->addConnection('bolt', 'bolt://neo4j:mypassword@localhost:7687/db')
->build();
$check_1_node = "MATCH (b) WHERE b.name = '{$_POST['node1']}' OR b.name = '{$_POST['node2']}' RETURN b";
$check = $client->run($check_1_node);
$result = $check->getRecords();
if (count($result) == 1) {
//Add second node and relation
echo "There is really one node!"
foreach ($result as $record) {
echo $record->value();
}
//$add_second_node = "CREATE (b1 { name: '{$_POST['node2']}' })";
//$client->run($add_second_node);
}
The output is just:
There is really one node!
If I call
echo $result;
it claims the $result is an array:
array
When trying to test a different approach with different functions something like this is thrown:
Call to undefined method GraphAware\Bolt\Result\Result::getResultSet() in /home/paul/LitGraphs/create.php:14
I'm quite newbie for both php and Neo4j, so will appreciate every clue, including obvious.
Upvotes: 0
Views: 199