Edit this Page


Both Database and Driver instances provide access to transaction management for your queries. You can manage transactions manually or use pre-created Closure based flow.


To start and commit transaction manually use begin and commit methods of Database:

//Your queries


//Your queries

Alternative Approach

You can let Database manage state of your transaction automatically using transaction method:

$this->db->transaction(function (Database $db) {

Transaction will be rolled back in case of any exception.