best way to handling error in medoo insert query or other query
The code in all queries properly. For example, when multiple records insert whid insert() method output is an array.
1:
try{
$db->pdo->beginTransaction();
$deletes=$db->delete("table",array("c_id"=>$id));
if($deletes===false || $deletes===null){
throw new Exception();
}
$res=$db->insert("tm_channel_admins",$insertsArray);
if($res===false || $res===null){
throw new Exception();
}
$db->pdo->commit();
}catch (Exception $e){
$db->pdo->rollBack();
exit("Error");
}
2:
$res=$db->insert("tm_channel_admins",$insertsArray);
if($db->error()[0]!==0){
throw new Exception();
}
what is true and safe?