Joomla 数据库使用事务
$db = JFactory::getDBo();
try{
// 开启事务
$db->transactionStart();
// 提交
$db->transactionCommit();
$res = new StdClass();
$res->err = (object) ['code' => 0, 'msg' => '发送成功'];
$res->data = [];
echo json_encode($res);
}catch(Exception $e){
// 回滚
$db->transactionRollback();
$res = new StdClass();
$res->err = (object) ['code' => 1, 'msg' => $e->getMessage()];
$res->data = [];
echo json_encode($res);
}