2017-04-06 15:51
浏览 60


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 = {name} RETURN id(n)', ['name' => 'Michal']);
$tx->push('CREATE (n:Person) RETURN id(n)');
$results = $tx->commit();

图片转代码服务由CSDN问答提供 功能建议

第二个代码行中的运行查询是原子事务的一部分,换句话说:是否可能 另一个线程在以下代码的第2行和第4行之间成功运行查询?

  $ tx = $ client-> transaction(); 
 $ result = $ tx  - > run('CREATE(n:Person)SET = {name} RETURN id(n)',['name'=>'Michal']); 
 $ tx-> push('  CREATE(n:Person)RETURN id(n)'); 
 $ results = $ tx-> commit(); 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dqt66847
    dqt66847 2017-04-08 21:38

    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.

    点赞 评论