Ensure db is in transaction to commit or rollback.
This commit is contained in:
parent
701caae7eb
commit
7beb161d2b
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user