0

我在 PHP 5.6.24 上使用 graphaware/neo4j-php-client 4.5.1 和 Neo4j 3.0.4。

我不明白如何找出交易是否失败。

例如,我尝试删除仍然有关系的节点。如果我在这个简单的查询中运行 DELETE:

$client->run
(
    'MATCH (node { name: {name} }) DELETE node',
    [ 'name' => 'Fred' ]
);

......我得到了这个异常,这是我所期望的行为:

[GraphAware\Neo4j\Client\Exception\Neo4jException]
  org.neo4j.kernel.api.exceptions.ConstraintViolationTransactionFailureException: 
  Cannot delete node<31>, because it still has relationships. 
  To delete this node, you must first delete its relationships.

但是当我将相同的查询包装在事务中时:

$transaction = $client->transaction();

$transaction->push
(
    'MATCH (node { name: {name} }) DELETE node',
    [ 'name' => 'Fred' ]
);

$results = $transaction->commit();

foreach ($results as $result)
{
    $summary = $result->summarize();
    $stats = $summary->updateStatistics();
    printf("Nodes deleted: %d\n", $stats->nodesDeleted());
}

printf("Transaction status: %s\n", $transaction->status());

... Neo4j 不会删除节点,但我看到了这个(暗示成功)而不是异常:

Nodes deleted: 1
Transaction status: COMMITED

我错过了什么,还是这是一个错误?提前致谢!

4

1 回答 1

1

谢谢,

这实际上是一个错误,我在https://github.com/graphaware/neo4j-php-client/commit/af8f01475a3cf63549498449574eb9c4bb8e7254中修复了它

包含此修复程序的 4.5.3 版本应该会在几分钟后在 packagist 上可用。

请测试并报告。

于 2016-09-04T22:07:25.253 回答