Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

DB::beginTransaction()

/* method provided by the DB facade: */
use IlluminateSupportFacadesDB;
 
DB::beginTransaction();
//You can rollback the transaction via the rollBack method:
DB::rollBack();
//Lastly, you can commit a transaction via the commit method:
DB::commit();
//EXP : 
// Open a try/catch block
try {
    // Begin a transaction
    DB::beginTransaction();
    // Do something and save to the db...
  
    // Commit the transaction
    DB::commit();
} catch (Exception $e) {
    // An error occured; cancel the transaction...
    DB::rollback();
    // and throw the error again.
    throw $e;
}
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
8+5 =