(c:Country) RETU" /> (c:Country) RETU" /> (c:Country) RETU"/>

php neo4j get related node

43 views Asked by At

I'm using neo4jphp and performing following query using \Everyman\Neo4j\Cypher\Query

"MATCH (p:Person) OPTIONAL MATCH (p)-[:CITIZEN]->(c:Country) RETURN p, c ";

I can get properties of Person

$props = $row['x']->getProperties();

How can I get country of the person? printing $row I can see country field, but I couldn't find methods in the docs and sources.

1

There are 1 answers

0
Josh Adell On

Row objects implement the ArrayAccess interface, so can be accessed like arrays. Assuming from your query that the row has properties 'p' for the Person and 'c' for the Country, you can access the country node object like:

$country = $row['c'];