Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Delegated database transaction support.

Copyright: 2009 Petr Skoda (http://skodak.org)
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 107 lines (3 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

moodle_transaction:: (6 methods):
  __construct()
  get_backtrace()
  is_disposed()
  dispose()
  allow_commit()
  rollback()


Class: moodle_transaction  - X-Ref

Delegated transaction class.

__construct($database)   X-Ref
Delegated transaction constructor,
can be called only from moodle_database class.
Unfortunately PHP's protected keyword is useless.

param: moodle_database $database

get_backtrace()   X-Ref
Returns backtrace of the code starting exception.

return: array

is_disposed()   X-Ref
Is the delegated transaction already used?

return: bool true if commit and rollback allowed, false if already done

dispose()   X-Ref
Mark transaction as disposed, no more
commits and rollbacks allowed.
To be used only from moodle_database class

return: null

allow_commit()   X-Ref
Commit delegated transaction.
The real database commit SQL is executed
only after committing all delegated transactions.

Incorrect order of nested commits or rollback
at any level is resulting in rollback of SQL transaction.

return: void

rollback($e)   X-Ref
Rollback all current delegated transactions.

param: Exception|Throwable $e mandatory exception/throwable
return: void