neoxygen / neo4j-neoclient

Simple PHP HttpClient for the Neo4j ReST API with Multi DB Support
MIT License
121 stars 138 forks source link

getResult returns nothing #74

Closed ivan83 closed 8 years ago

ivan83 commented 8 years ago

Hi,

I am trying to run this piece of code (similar to a problem I have found here):

$query = "match (i:institutions)-[:worksAt]-(n:persons) WHERE toLower(i.name) CONTAINS toLower('moldova') return n";

$neo = $this->client->sendReadQuery($query);

$results = $this->client->getResult();
//tried this too:
//$results = $neo->getResult();

foreach ($results->getNodes() as $node)
{
    $nodes[] = [
        'name' => $node->getProperty('name'),
        'id' => $node->getId()
    ];
}

When I do print_r on $neo right after sendReadQuery, I can see the object, and the result of the query is there, just one row. Problem is, $results is emty, it is not an object. I have tried getRows(), getTableFormat(), all sort of combinations, nothing works. getResponse returns me that same object with which none of the functions work. All I want to do is get all the nodes out with their properties in some sort of array.

It must be something really simple I am missing out.

Thanks, Ivan

ivan83 commented 8 years ago

This is how printed out $neo object looks like if it helps. neo.txt

ikwattro commented 8 years ago

Hi,

Sorry for the delay.

It looks like you don't have the response formatting service enabled, can you give me the lines where you configure the client.

Or ideally check if you have

setAutoFormatResponse(true)

in the client build

ivan83 commented 8 years ago

Hi,

Thanks for the reply. No, I do not. I did not know it was needed.

I turned to writing my own class that uses REST API directly as a temporary solution for now. I will try this when I get some time.

ikwattro commented 8 years ago

The Response formatting do the parsing of the rest api for you and hydrate the response to the result object with nodes and relationships.

In the meantime, please be aware that this Client has been recently acquired by GraphAware, the company I work for, there are no changes currently, you can still use Neoxygen\NeoClient but the next major release will happen at https://github.com/graphaware/neo4j-php-client.

The good thing is that, as we use Neo4j everyday, you can be certain of the client compatibility ;-)