Neo4jPHP事务查询:在查询构造中获取错误

时间:2015-03-15 15:11:32

标签: neo4j neo4jphp

我正在尝试使用Jadell的Neo4jPHP实现基于事务的基本查询。

这是我的代码:

$transaction = $client->beginTransaction();
$query = new Query($client, "CREATE UNIQUE (u:users {email})-[r:visited {'time':'1425283200'}]->(e:halls {hallId}) RETURN r", array('email' => array('email' => 'test@test.com'), 'hallId' => array('hallId' => 1234)));
$result = $transaction->addStatements($query);
$transaction->commit();

我收到错误:

  

[message] =>输入'''无效:预期的空格,属性键   name,'}',标识符或UnsignedDecimalInteger(第1行,列   52)\ n

关于这里出了什么问题的任何线索?

更新

我尝试了以下(删除参数)并仍然收到错误:

$transaction = $client->beginTransaction();
$query = new Query($client, "CREATE UNIQUE (u:users {'email':'" . $email . "'})-[r:visited]->(e:halls {'hallId':'" . $hallId . "'}) RETURN r");
$result = $transaction->addStatements($query);
$transaction->commit();

收到错误:

  

[message] =>无法反序列化请求:无法反序列化   START_ARRAY标记中的java.util.LinkedHashMap实例\ n

1 个答案:

答案 0 :(得分:0)

这应该有效。 使用查询参数而不是字符串连接

$transaction = $client->beginTransaction();
$cypher="CREATE UNIQUE (u:users {email:{email}})-[r:visited]->(e:halls {hallId:{hallId}}) RETURN r";
$query = new Query($client,$cypher,array('email'=>$email,'hallId'=>$hallId));
$result = $transaction->addStatements($query);
$transaction->commit();