neo4jphp relateTo() to a getResultSet() object -
i'm using neo4jphp rest api , i'm having problem of relating node iv created in code node im retrieving neo4j database. i'm retrieving node follows
$querystring="match(n)"."where has (n.name) , n.name='interests'"."return n"; $query=new everyman\neo4j\cypher\query($client,$querystring); $result=$query->getresultset();
im creating node in code using createnode() $friend=$client->makenode()->setproperty('name',$fname)->save();
used relateto() relate them
$m=$client->getnode($result); $m->relateto($friend,$movi)->save();//$movi common movie name
but getting error
php catchable fatal error: object of class everyman\\neo4j\\query\\resultset not converted string in /var/www/vendor/everyman/neo4jphp/lib/everyman/neo4j/cache/entitycache.php
would appreciate input
a neo4jphp query returns row object (even if theres 1 responce) so
$m=$client->getnode($result);
won't work
try instead
$querystring="match(n) has (n.name) , n.name='interests' return n"; $query=new everyman\neo4j\cypher\query($client,$querystring); $result=$query->getresultset(); foreach($result $resultitem) { $resultarray[] = $resultitem['x']; //$resultitem['x'] node object, $result array array of node objects } $friend= $client->makenode()->setproperty('name',$fname)->save(); $resultarray[0]->relateto($friend,$movi)->save();
this code work query (easier read)
$querystring="match (n {name:"interests"}) return n";
Comments
Post a Comment