/**
* 事务封装方法
* @access public 将此方法放入框架model.class.php中
* @param array $sqls 要执行的sql数组或语句
* @param array $vals sql语句中要替换的值
* @return boolean
*/
public function transExecuteSql($sqls)
{
$this->startTrans();
if(is_array($sqls))
{
foreach($sqls as $k => $sql)
{
$result=$this->db->execute($sql);
if(!$result)
{
$this->rollBack();
return false;
}
}
}else{
$result=$this->db->execute($sqls);
if(!$result)
{
$this->rollBack();
return false;
}
}
$this->commit();
return true;
}
转载于:https://www.cnblogs.com/pengyunjing/p/6607741.html