Question

I tried to execute some custom queries using DB::execute() function by passing query as a parameter to this function - update query on existing table. Before running this query I checked the connection object like this $connection = DB::getConnection(); and it returned a connection identifier. Then while executing query it returned bool true from execute function, though changes were not there in database table fields. Also if I pass query with wrong syntax, it is giving error.

Is there any rollback process going on in background with update query statement in ActiveCollab? If yes how to stop this rollback to avoid the changes done by my update query ?

Could anyone tell me what could be the issue here ?

Was it helpful?

Solution

All uncommitted transactions are automatically rolled back on script shutdown so you need to make sure that you are committing transactions that you opened:

try {
  DB::beginWork();

  // Do something

  DB::commit();
} catch(Exception $e) {
  DB::rollback();
  throw $e;
}

or:

DB::transact(function() {
  // Do something
});

If you are within a nested transaction and outer transactions gets rolled back, your updates will be rolled back as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top