diff --git a/common/persistence/class.SqlPersistence.php b/common/persistence/class.SqlPersistence.php index 54fe82ff6..c478d2f29 100755 --- a/common/persistence/class.SqlPersistence.php +++ b/common/persistence/class.SqlPersistence.php @@ -123,4 +123,18 @@ public function quote($parameter, $parameter_type = PDO::PARAM_STR){ public function lastInsertId($name = null){ return $this->getDriver()->lastInsertId($name); } + + /** + * Execute a function within a transaction. + * + * @param Closure $func The function to execute transactionally. + * + * @return mixed The value returned by $func + * + * @throws Throwable + */ + public function transactional(Closure $func) + { + return $this->getDriver()->transactional($func); + } } diff --git a/common/persistence/sql/dbal/class.Driver.php b/common/persistence/sql/dbal/class.Driver.php index 6f7816303..22ee3f5e2 100755 --- a/common/persistence/sql/dbal/class.Driver.php +++ b/common/persistence/sql/dbal/class.Driver.php @@ -243,4 +243,19 @@ public function getDataBase() { return $this->connection->getDatabase(); } + + /** + * Execute a function within a transaction. + * + * @param Closure $func The function to execute transactionally. + * + * @return mixed The value returned by $func + * + * @throws Exception + * @throws Throwable + */ + public function transactional(Closure $func) + { + return $this->connection->transactional($func); + } }