在 medoo 插入查询或其他查询中处理错误的最佳方法
所有查询中的代码正确。例如,当插入多个记录时,insert() 方法的输出是一个数组。
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();
}
什么是真实和安全的?