Ensure db is in transaction to commit or rollback.

This commit is contained in:
KJ 2024-06-02 11:31:37 -04:00
parent 701caae7eb
commit 7beb161d2b
1 changed files with 8 additions and 2 deletions

View File

@ -85,7 +85,10 @@ class Model {
*/
public function rollBack(): bool
{
return static::db()->rollBack();
if ( static::db()->inTransaction())
return static::db()->rollBack();
else
return true;
}
/**
@ -96,7 +99,10 @@ class Model {
*/
public function commit(): bool
{
return static::db()->commit();
if (static::db()->inTransaction())
return static::db()->commit();
else
return true;
}
/**