Reputation: 69
I am new to neo4j.
I want to retrieve the auto generated id of the node using a cypher query.
I am using php.
How is it possible? Also,how do I get just the id of the node in a php variable?
Upvotes: 1
Views: 950
Reputation: 9952
MATCH (n)
RETURN ID(n) as nodeId
See docs: http://docs.neo4j.org/chunked/milestone/query-functions-scalar.html#functions-id
EDIT:
I don't know PHP well but assuming you're using neo4jphp
I guess the general idea would be something like
$client = new Everyman\Neo4j\Client();
$queryString = "MATCH (n) RETURN ID(n) as nodeId";
$query = new Everyman\Neo4j\Cypher\Query($client, $queryString);
$result = $query->getResultSet();
echo $result[0]['nodeId']
You will want to read up on neo4jphp
here, particularly how to use cypher. Or you can use php cURL with Neo4j REST API.
Upvotes: 2