Neo4jphp中的几个平行批次
是否可以一次创建多个批次 例如,我有一个正在运行的批处理(批处理1)的代码。在这个批中,我有一个名为的方法,其中有另一个批(第2批)。代码不起作用 当我删除上面的批(批1)时,我创建了一个节点。也许一次只能有一批 示例代码如下所示:Neo4jphp中的几个平行批次,neo4j,neo4jphp,Neo4j,Neo4jphp,是否可以一次创建多个批次 例如,我有一个正在运行的批处理(批处理1)的代码。在这个批中,我有一个名为的方法,其中有另一个批(第2批)。代码不起作用 当我删除上面的批(批1)时,我创建了一个节点。也许一次只能有一批 示例代码如下所示: $batch = $client->startBatch(); $widget = NULL; try { $widgetLabel = $client->makeLabel('Widget'); $widget = $client
$batch = $client->startBatch();
$widget = NULL;
try {
$widgetLabel = $client->makeLabel('Widget');
$widget = $client->makeNode();
$widget
->setProperty('base_filename', md5(uniqid('', TRUE)))
->setProperty('datetime_added', time())
->setProperty('current_version', 0)
->setProperty('shared', 0)
->setProperty('active', 1)
->save();
// add widget history
$history = Model_History::create($widget, $properties);
if ($history == NULL) {
throw new Exception('Could not create widget history!');
}
$widget->setProperty('current_version', $history->getID());
$widget->save();
$client->commitBatch($batch);
} catch (Exception $e) {
$client->endBatch();
}
批处理2位于Model_History::create()方法中。我没有从这段代码中获得有效的$widget-Neo4jphp节点。如果第二批是通过另一个调用
$client->startBatch()
创建的,它实际上将是与$batch
相同的批处理对象。如果从那里调用$client->commitBatch()
,它将提交外部批处理(因为它们是相同的)
不要在
Model\u History::create()
中启动第二批。启动外部批处理,检查所有代码,最后提交一次。因此没有办法拥有多个独立批处理?您可以使用新批处理($client)
手动创建批处理。为什么需要两个并行批处理?Josh Adell,我想知道代码的每个独立部分都在事务中运行。我会试试你提出的解决办法。谢谢