Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.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