/**
* @var array Database drivers that support SAVEPOINT * statements.
*/
- protected static $_supportedDrivers = ["pgsql", "mysql"];
+ protected static $_supportedDrivers = ['pgsql', 'mysql'];
/**
* @var int the current transaction depth
/**
* Commit current transaction
*
- * @return bool|void
+ * @return bool
*/
- public function commit()
+ public function commit(): bool
{
// We don't want to "really" commit something, so skip the most outer hierarchy
if ($this->_transactionDepth <= 1 && $this->hasSavepoint()) {
$this->_transactionDepth--;
- $this->exec("RELEASE SAVEPOINT LEVEL{$this->_transactionDepth}");
+ return $this->exec("RELEASE SAVEPOINT LEVEL{$this->_transactionDepth}");
}
/**
* Rollback current transaction,
*
* @throws PDOException if there is no transaction started
- * @return bool|void
+ * @return bool Whether rollback was successful
*/
- public function rollBack()
+ public function rollback(): bool
{
$this->_transactionDepth--;
- if($this->_transactionDepth <= 0 || !$this->hasSavepoint()) {
+ if ($this->_transactionDepth <= 0 || !$this->hasSavepoint()) {
$this->_transactionDepth = 0;
try {
- parent::rollBack();
+ return parent::rollBack();
} catch (PDOException $e) {
// this shouldn't happen, but it does ...
}
} else {
- $this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->_transactionDepth}");
+ return $this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->_transactionDepth}");
}
+ return false;
}
}