开发者

Transactions within the Node's API CRUD callback (Drupal)

开发者 https://www.devze.com 2023-04-11 06:39 出处:网络
Should I call the db_开发者_如何学Gotransaction() inside the node\'s CRUD hook (like hook_load, hook_insert, etc)?

Should I call the db_开发者_如何学Gotransaction() inside the node's CRUD hook (like hook_load, hook_insert, etc)?

UPD: The crux of the matter is, for example, the hook_update and hook_insert functions are called from the node_save(), and it's code is already wrapped in a transaction.


If you're performing multiple queries and want the option to rollback on failure of one of them then yes. It's safe to do so as each db_transaction goes out of scope when the function it's in is finished running, so you should never be in a position where you're starting a new transaction while another one is already open so to speak.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号