开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜