When the script ends or when a connection is about to be closed, if you have an outstanding transaction, PDO will automatically roll it back. This is a safety measure to help avoid inconsistency in the cases where the script terminates unexpectedly--if you didn't explicitly commit the transaction, then it is assumed that something went awry, so the rollback is performed for the safety of your data.
Since Octane never actually quits, the transaction will still exist after the request has ended.
Consider the following code:
DB::beginTransaction();
User::create(['name' => $request->input('name')]);
if (someCondition()) {
abort(403);
)
DB::commit();
If for some reason someCondition() is true, the request is aborted, but the transaction is not ended.
If the user tries again and someCondition() is false, then both the new and previous 'User' model is created.
Fixes
909
Unfortunately I don't know how to test this. Hopefully someone will add it.
PHP PDO transactions
Since Octane never actually quits, the transaction will still exist after the request has ended.
Consider the following code:
If for some reason someCondition() is true, the request is aborted, but the transaction is not ended. If the user tries again and someCondition() is false, then both the new and previous 'User' model is created.
Fixes
909
Unfortunately I don't know how to test this. Hopefully someone will add it.