We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Similar to #6360 but issue is because of commit method. Calling commit method first will make transactionLevel go below 0.
DB::commit(); echo DB::transactionLevel(); // -1
Now calling DB::transaction() will not beginTransaction as transactionLevel is 0 but all changes are updated in database and rollBack is not possible.
DB::transaction(function() { echo DB::transactionLevel(); // 0 DB::delete('DELETE FROM table_name'); throw new Exception('foo'); // no rollBack happens });
Shouldn't the commit method have a check on transactions like rollBack method?
--$this->transactions; // instead of this $this->transactions = max(0, $this->transactions - 1); // use this
Or throw exception when trying to commit when there is no transaction?
if ($this->transactions === 0) { throw new RuntimeException('There is no active transaction'); }
The text was updated successfully, but these errors were encountered:
$this->transactions = max(0, $this->transactions - 1); // use this
No, that's just a hack that's not actually fixing the real issue.
Sorry, something went wrong.
Wouldn't it be better to throw an exception when commit and rollBack methods are called with 0 transactionLevel?
No branches or pull requests
Similar to #6360 but issue is because of commit method.
Calling commit method first will make transactionLevel go below 0.
Now calling DB::transaction() will not beginTransaction as transactionLevel is 0 but all changes are updated in database and rollBack is not possible.
Shouldn't the commit method have a check on transactions like rollBack method?
Or throw exception when trying to commit when there is no transaction?
The text was updated successfully, but these errors were encountered: