我在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
我错过了什么,或者这是一个错误?提前谢谢!
答案 0 :(得分:1)
谢谢,
这实际上是一个错误,我在https://github.com/graphaware/neo4j-php-client/commit/af8f01475a3cf63549498449574eb9c4bb8e7254
中修复了它包含此修复程序的4.5.3版本应在几分钟内在packagist上提供。
请测试并报告。