$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);
}
作者:张敏
原文:http://www.joomlachina.cn/shouce/doc/1916?article_id=1782