neo4jphp
neo4jphp copied to clipboard
addLabels to node fails in Batch mode
Hi,
I am very new with neo4j and of course with neo4jphp, so i dont know if i am missing something.
When the batch mode is on and i create a node and after i add label, then throw an exception about the node is not saved
$batch = $this->neo4->startBatch();
$label = $this->neo4j->makeLabel(self::LABEL_USER);
$partner = $this->neo4j->makeNode();
$partner
->setProperty('mongoId', (string) $origin->getId())
->setProperty('slug', $origin->getSlug())
->setProperty('name', $origin->getName())
->save();
$node->addLabels([$label]);
$batch->commit();
How i can create a node and add a label in batch mode? Is this possible?
Regards and thanks
Hello I have the same problem, someone can help or explain another way to do this.
Regards
I made a PR but i not accepted because in under way another implementation.
https://github.com/jadell/neo4jphp/pull/95
I think that i found some solution... @ Everyman\Neo4j\Command\SetLabels on __constructor
$nodeId = $node->getId();
if (!$nodeId) {
throw new \InvalidArgumentException("Cannot set labels on an unsaved node");
}
to
$nodeId = $node->getId();
if (!$nodeId) {
if($nodeId != 0)
{
throw new \InvalidArgumentException("Cannot set labels on an unsaved node");
}
}
Some times the $node is equles to 0 and it comfusing between false and Node#0