Reputation: 4624
I am new to Neo4j. I have the following query in which I tried to parametrize the depth
value for the relationship and it shows an error, If I remove parametrizing the depth
value it works perfectly.
$query="MATCH (a:user{id:{usd}})-[:likes*1..{depth}]->(b:product{id:{pid}})
return a";
$result = new Everyman\Neo4j\Cypher\Query($client, $query,
array('usd' => 1234,'depth' => 3,'pid'=>3456));
Please help, Thanks in advance
Upvotes: 4
Views: 119
Reputation: 5001
Your conclusion is correct and this is not a problem related to neo4jphp. Cypher does not allow you to parameterize the depth of a relationship. If your depth has to be dynamic, you'll have to build your query like this:
$depth=some_value;
$query="MATCH (a:user{id:{usd}})-[:likes*1.." . $depth . "]->(b:product{id:{pid}})
return a"
I'm not a PHP developer, so the syntax might not be 100% correct. But I guess the main idea is clear.
Upvotes: 2