Model Transactions
Model Transactions
When a process performs multiple database operations, it might be important that each step is completed successfully so that data integrity can be maintained. Transactions offer the ability to ensure that all database operations have been executed successfully before the data is committed to the database.
Transactions in Phalcon allow you to commit all operations if they were executed successfully or rollback all operations if something went wrong.
Manual Transactions
If an application only uses one connection and the transactions aren’t very complex, a transaction can be created by just moving the current connection into transaction mode and then commit or rollback the operation whether it is successful or not:
use Phalcon\Mvc\Controller; class RobotsController extends Controller { public function saveAction() { //