phpneo4jtransactionsgraphaware

Is running a transaction followed by php code and then a commit atomical in neo4j-php-client?


Is the run query in the second code line part of the atomical transaction, or in other words: is it possible that another thread runs a query successfully between the 2nd and 4th line of the following code?

$tx = $client->transaction();
$result = $tx->run('CREATE (n:Person) SET n.name = {name} RETURN id(n)', ['name' => 'Michal']);
$tx->push('CREATE (n:Person) RETURN id(n)');
$results = $tx->commit();

Solution

  • PHP is thread safe and shares nothing between threads.

    So no, it is not possible that another thread will run a query in the same transaction as the one opened by the current thread, it will rather use its own transaction.