In my application I use BEGIN;
, COMMIT;
, ROLLBACK;
, Try
, Catch
:
Example:
try{
$this->execute('BEGIN;');
// CODIGO COM VALIDAÇÕES
$this->execute('COMMIT;');
}catch(Exception $e){
$this->execute('ROLLBACK;');
}
It turns out that for test purposes I hedge a flag that activates BEGIN;
, ROLLBACK;
Global
Example
function __construct(){
if($this->transaction_rollback === true){
$this->Execute('BEGIN;');
}
}
function __destruct(){
if($this->transaction_rollback === true){
$this->Execute('ROLLBACK;');
}
}
Summary
BEGIN;
BEGIN; //there is already a transaction in progress
// INSERT
COMMIT;
ROLLBACK; //there is no transaction in progress
Situation
I use postgreSql
and by testing it does not support multi BEGIN;
,
investigating a landing I also did not find other banks that would support this situation.
Question
Would you have any other way to protect the bank for testing purposes?