Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

avoid data insertion if an error occurs in laravel

try {
        //start the transaction
        DB::beginTransaction();

        DB::table('XYZ')->update(['abc'=>'ABC']);
        DB::table('EG')->delete();

        //commit the transaction
        DB::commit();
} catch (Exception $e) {
        DB::rollBack();
        return response;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #avoid #data #insertion #error #occurs #laravel
ADD COMMENT
Topic
Name
7+7 =