Ensure db is in transaction to commit or rollback.
This commit is contained in:
parent
701caae7eb
commit
91615c086d
@ -72,9 +72,12 @@ class Model {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function beginTransaction(): bool
|
public function rollBack(): bool
|
||||||
{
|
{
|
||||||
return static::db()->beginTransaction();
|
if ( static::db()->inTransaction())
|
||||||
|
return static::db()->rollBack();
|
||||||
|
else
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,9 +86,12 @@ class Model {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function rollBack(): bool
|
public function commit(): bool
|
||||||
{
|
{
|
||||||
return static::db()->rollBack();
|
if (static::db()->inTransaction())
|
||||||
|
return static::db()->commit();
|
||||||
|
else
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user