...
Transactions offer a method of executing queries in series, with the ability to roll back to a previous state if an error occurs. Any database error will throw a PDOException.
Note |
---|
title | Transactions must be supported by the database engine |
---|
|
Blesta uses the InnoDB engine for all of its tables, and you are encouraged to do the same. Transactions will fail on database engines that do not support transactions. |
Using Transactions
Code Block |
---|
|
try {
// Begin transaction
$this->Record->begin();
// Run queries...
// Commit queries
$this->Record->commit();
}
catch (PDOException $e) {
// Rollback the queries, error occurred.
$this->Record->rollback();
} |