1
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 choose a flag that activates the 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 the tests it does not have support to multi BEGIN;
,
researching a landing also did not find other banks that would support this situation.
Question
Would have some other way to protect the bank for testing purposes?
Are you by any chance confusing "multiples Begin" with savepoint ? -> http://www.postgresql.org/docs/8.1/static/sql-savepoint.html
– wryel