【发布时间】:2014-05-18 10:02:00
【问题描述】:
我需要触发 2 个查询。目前我正在这样做:
// Begin Transaction
$this->db->beginTransaction();
// Fire Queries
if($query_one->execute()){
if($query_two->execute()){
// Commit only when both queries executed successfully
$this->db->commit();
}else{
$this->db->rollback();
}
}else{
$this->db->rollback();
}
这是正确的方法吗?我没有在我的代码中使用任何 try..catch 是否会使我的代码在任何情况下都不合适或易受攻击?
【问题讨论】:
标签: php mysql pdo commit rollback