Aquesta pàgina forma part de la documentació de Moodle en català, tot i que no ha estat traduïda encara. Podeu contribuir obertament a les tasques de traducció. Podeu consultar la Guia d'edició de la documentació i també participar ens els debats del fòrum de traductors de la documentació a moodle.org

Broken/DB layer 2.0 delegated transactions

De MoodleDocs
Salta a:navegació, cerca

Alternate API (from comments in Tracker/HQ chat

6. Normal usage of the moodle_delegated_transaction will be: $transaction = $DB->start_require_transaction(); // Perform some $DB stuff $transaction->end_require_transaction(); 7. If, for any reason, developer needs to catch exceptions when using transactions, it will be mandatory to use it in this way: try {

   $transaction = $DB->start_require_transaction();
   // Perform some $DB stuff
   $transaction->end_require_transaction();

} catch (exception $e) {

   $transaction->rollback($e); // ?

} 8. In order to be able to keep some parts of code out from top transactions completely, if we know it can lead to problems, we can use:

$DB->forbide_transaction(); // Instant check to confirm we aren't using transactions in this point. Will throw exception if transaction is found.