I'm planing to use Try/Catch and Database Transaction in Laravel5 and my own PHP project to validate any errors occurs then rollback avoiding lost my transaction or information during user do their transaction to Database. I'm sure to find out if some method done with success status or non success status but I don't understand much yet about Try/Catch with Database transaction specially with BeginTransaction() and Commit(). Rollback() buildin method in Larvel5. I have done with this function but finally I don't know how many errors type will happen during those transaction. When and how catch find those (if error happen) errors and return to users? In Return under DB::commit() method I will return all status to end user but how about catch do their task if error happen and what kind of those errors. Example:\
public function my_method(){
DB::beginTransaction():
try {
$this->data['a'] = $this->select();
$this->data['b'] = $this->delete();
$this->data['c'] = $this->update();
$this->data['d'] = $this->insert();
DB::commit();
return ['data'=>$this->data];
//I planing return all the return back from each method to user.
} catch(EXCEPTION $e){
DB::rollback()
throw $e
}
}
private update(){ if(done){return true}}
private delete(){ if(done){return true}}
private insert(){ if(done){return true}}
private select(){ if(done){return true}}